Top "C" questions

C is a general-purpose programming language used for system programming (OS and embedded), libraries, games and cross-platform.

Reading a file character by character in C

I'm writing a BF interpreter in C and I've run into a problem reading files. I used to use scanf …

c file-io io iostream
default value for struct member in C

Is it possible to set default values for some struct member? I tried the following but, it'd cause syntax error: …

c struct
Where do I find the definition of size_t?

I see variables defined with this type but I don't know where it comes from, nor what is its purpose. …

c++ c variables
Difference between return 1, return 0, return -1 and exit?

For example consider following code: int main(int argc,char *argv[]) { int *p,*q; p = (int *)malloc(sizeof(int)*10); q = (…

c return exit
How to compile makefile using MinGW?

I'm new to this. Just wanted to ask how to compile a makefile. I am using MinGW compiler in C …

c compiler-construction makefile mingw
What is exactly the base pointer and stack pointer? To what do they point?

Using this example coming from wikipedia, in which DrawSquare() calls DrawLine(), (Note that this diagram has high addresses at the …

c++ c assembly x86
Generate random numbers following a normal distribution in C/C++

How can I easily generate random numbers following a normal distribution in C or C++? I don't want any use …

c++ c random distribution normal-distribution
Rounding up to next power of 2

I want to write a function that returns the nearest next power of 2 number. For example if my input is 789, …

c optimization bit-manipulation
How to make a variadic macro (variable number of arguments)

I want to write a macro in C that accepts any number of parameters, not a specific number example: #define …

c g++ c-preprocessor variadic
Passing an array as an argument to a function in C

I wrote a function containing array as argument, and call it by passing value of array as follows. void arraytest(…

c arrays function parameters parameter-passing