Proper way to empty a C-String

It depends on what you mean by “empty”. If you just want a zero-length string, then your example will work. This will also work: If you want to zero the entire contents of the string, you can do it this way: but this will only work for zeroing up to the first NULL character. If … Read more

What do numbers using 0x notation mean?

Literals that start with 0x are hexadecimal integers. (base 16) The number 0x6400 is 25600. For an example including letters (also used in hexadecimal notation where A = 10, B = 11 … F = 15) The number 0x6BF0 is 27632.

When to use const char * and when to use const char []

Both are distinctly different, For a start: The First creates a pointer. The second creates an array. Read on for more detailed explanation: The Array version: Creates an array that is large enough to hold the string literal “text”, including its NULL terminator. The array text is initialized with the string literal “text”.The array can be modified at a … Read more

Categories c Tags ,

What is signed integer overflow?

Your while condition will always be true, meaning the loop will run forever, adding 1 to c in each iteration. Since c is a (signed) int it means it will increment slowly to its max value, and after that the next increment would be UB (undefined behavior). What many machines will do in this specific UB is to turn c negative, which I … Read more

How can one see content of stack with GDB?

info frame to show the stack frame info To read the memory at given addresses you should take a look at x x/x $esp for hex x/d $esp for signed x/u $esp for unsigned etc. x uses the format syntax, you could also take a look at the current instruction via x/i $eip etc.

Undefined reference to main – collect2: ld returned 1 exit status

It means that es3.c does not define a main function, and you are attempting to create an executable out of it. An executable needs to have an entry point, thereby the linker complains. To compile only to an object file, use the -c option: The above compiles es3.c to an object file, then compiles a file main.c that would contain the main function, and the linker merges es3.o and main.o into … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)