254 Answered Questions for the topic C

C

06/03/19

How can I autoformat/indent C code in vim?

When I copy code from another file, the formatting is messed up, like this: fun() { for(...) { for(...) { if(...) { } } } }How can I autoformat this code in vim?
C

06/03/19

What do the parentheses around a function name mean?

In one of my project source files, I found this C function definition: int (foo) (int *bar) { return foo (bar); }Note: there is no asterisk next to `foo`, so it's not a function... more
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

How to convert TargetLink model to Simulink?

I'm new to Targetlink and need to convert Targetlink blocks to simulink blocks. Do I need Targetlink license for converting as well ?
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

Using of two Simulink/MATLAB static libraries?

I have C application which uses two **static** libraries. Source code for these libraries are generated and built by Simulink/MATLAB. The problem is that Simulink generates **extern non-static**... more
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/27/19

Matlab crash when running user defined blocks in simulink?

I created a user defined block with single input and single output in simulink and it works perfectly fine. But when i create a user defined block without an input, run this block in a simulink... 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?

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.