243 Answered Questions for the topic C

C

06/03/19

Why is the asterisk before the variable name, rather than after the type?

Why do most C programmers name variables like this: int *myVariable;rather than like this: int* myVariable;Both are valid. It seems to me that the asterisk is a part of the type, not a part... more
C

06/03/19

Passing variable number of arguments around?

Say I have a C function which takes a variable number of arguments: How can I call another function which expects a variable number of arguments from inside of it, passing all the arguments that... more
C

06/02/19

Matlab simulink Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks. Use 'mex -setup' to select a supported C-compiler?

I have a model in matlab simulink. I have installed matlab in D drive. When I run my model I get the following error: Unable to locate a C-compiler required by Stateflow and MATLAB Function... more

05/29/19

Is there a Java equivalent or methodology for the typedef keyword in C++?

Coming from a C and C++ background, I found judicious use of **`typedef`** to be incredibly helpful. Do you know of a way to achieve similar functionality in Java, whether that be a Java... more
C Java C++ D

05/29/19

Is D a credible alternative to Java and C++?

Is the [D language](http://www.digitalmars.com/d/) a credible alternative to Java and C++? What will it take to become a credible alternative? Should I bother learning it? Does it deserve... more
C

05/29/19

Printing all global variables/local variables?

How can I print all global variables/local variables? Is that possible in gdb?
C

05/29/19

Const pointer in typedef?

What does this line of code do': typedef const real_T * const * InputRealPtrsType; I think it defines `InputRealPtrsType` as a pointer to a constant pointer to a constant `real_T`. `real_T` is... more
C

05/28/19

The most efficient way to implement an integer based power function pow(int, int)?

What is the most efficient way given to raise an integer to the power of another integer in C? // 2^3 pow(2,3) == 8 // 5^5 pow(5,5) == 3125
C

05/28/19

Is 'switch' faster than 'if'?

Is a `switch` statement *actually* faster than an `if` statement?I ran the code below on Visual Studio 2010's x64 C++ compiler with the `/Ox` flag: #include <stdlib.h> #include... more
C

05/28/19

What is difference between Objective C and C?

C

05/28/19

Simulink: How to use a local variable in a level 2 s-function?

I have written a Simulink S-function (Level 2) in C. The resulting block has one output and one parameter. This parameter is stored in a variable, which is defined at file scope, right after... more
C

05/26/19

When should I use mmap for file access?

POSIX environments provide at least two ways of accessing files. There's the standard system calls `open()`, `read()`, `write()`, and friends, but there's also the option of using `mmap()` to map... more
C

05/26/19

What is the need for Labview for mechanical engineers

C

05/26/19

Convert first order transfer function to c code?

I have a simple first order transfer such as "3/s+3" or "tf(3,[1 3])" function and I would like to implement in c code. I have a C function that is called with the delta time since the last... more
C

05/26/19

What is the difference between char array vs char pointer in C?

I am trying to understand pointers in C but I am currently confused with the following:- char *p = "hello" This is a char pointer pointing at the character array, starting at _h_.- ... more

05/26/19

Why does the C preprocessor interpret the word "linux" as the constant "1"?

Why does the C preprocessor in GCC interpret the word `linux` (small letters) as the constant `1`? test.c: #include <stdio.h> int main(void) { int linux = 5; return 0; } Result of... more
C

05/26/19

Compiling C S-Function in MATLAB multiple definition error?

I am trying to compile various C-Functions in MATLAB Simulink using the S-function builder block and the minGW 64bit Compiler. A syntax error in the code is impossible since it is code from an ECU... more
C

05/26/19

static function in C?

What is the point of making a function static in C?
C

05/25/19

C sfunction & RTLAB?

I wrote a C sfunction and used it as a simulink block.It was OK.the answer is OK with the error about 10^-14 (in matlab enviroment)... Now I want to connect to RT_LAB, to run my model real... more
C

05/25/19

What is C used in?

C

05/25/19

Where does gcc look for C and C++ header files?

On a Unix system, where does gcc look for header files?I spent a little time this morning looking for some system header files, so I thought this would be good information to have here.
C

05/25/19

typedef struct vs struct definitions?

I'm a beginner in C programming, but I was wondering what's the difference between using `typedef` when defining a structure versus not using `typedef`. It seems to me like there's really no... more
C

05/21/19

Core dumped, but core file is not in the current directory?

While running a C program, It says *"(core dumped)"* but I can't see any files under the current path.I have set and verified the `ulimit`: ulimit -c unlimited ulimit -a I also tried to find... more
C

05/20/19

Why do you have to link the math library in C?

If I include `<stdlib.h>` or `<stdio.h>` in a C program I don't have to link these when compiling but I do have to link to `<math.h>`, using `-lm` with gcc, for example: gcc... more
C

05/20/19

How to initialize all members of an array to the same value?

I have a large array in C (not C++ if that makes a difference). I want to initialize all members to the same value. I could swear I once knew a simple way to do this. I could use `memset()` in my... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.