Top "C" questions

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

How to pass 2D array (matrix) in a function in C?

I need to do this to persist operations on the matrix as well. Does that mean that it needs to …

c multidimensional-array parameter-passing
#pragma pack effect

I was wondering if someone could explain to me what the #pragma pack preprocessor statement does, and more importantly, why …

c c-preprocessor pragma-pack
What is the strict aliasing rule?

When asking about common undefined behavior in C, people sometimes refer to the strict aliasing rule. What are they talking …

c undefined-behavior strict-aliasing type-punning
How to convert an enum type variable to a string?

How to make printf to show the values of variables which are of an enum type? For instance: typedef enum {…

c++ c preprocessor ansi-c
Two decimal places using printf( )

I'm trying to write a number to two decimal places using printf() as follows: #include <cstdio> int main() { …

c++ c printf decimal
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 …

c algorithm math exponentiation
Proper way to empty a C-String

I've been working on a project in C that requires me to mess around with strings a lot. Normally, I …

c string strcpy
What does the symbol \0 mean in a string-literal?

Consider following code: char str[] = "Hello\0"; What is the length of str array, and with how much 0s it is …

c++ c string escaping string-literals
unsigned int vs. size_t

I notice that modern C and C++ code seems to use size_t instead of int/unsigned int pretty much …

c++ c size-t
Using malloc for allocation of multi-dimensional arrays with different row lengths

I have the following C code : int *a; size_t size = 2000*sizeof(int); a = (int *) malloc(size); which works fine. …

c arrays malloc