So what does “return 0” actually mean?

Is it like php, where it returns its argument as the value of the function call? Is it just good practise? Yes, PHP and many other languages borrowed the return keyword from ‘C’. And in all the languages, the return keyword has the same function – to return from the function. Anything that follows return keyword is the value that is … Read more

Categories C Tags

What are .a and .so files?

Archive libraries (.a) are statically linked i.e when you compile your program with -c option in gcc. So, if there’s any change in library, you need to compile and build your code again. The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your … Read more

What is EOF in the C programming language?

On Linux systems and OS X, the character to input to cause an EOF is Ctrl–D. For Windows, it’s Ctrl–Z. Depending on the operating system, this character will only work if it’s the first character on a line, i.e. the first character after an Enter. Since console input is often line-oriented, the system may also not recognize the … Read more

What is the significance of return 0 in C and C++?

I need the simplest possible answer to this. I have looked up in various sites for the answer. If the inputs to a programme is such that the output is 10, will command return 0 force the programme to return the value 0 instead of 10? I have written simple C programmes on Borland IDE … Read more

Why unsigned int 0xFFFFFFFF is equal to int -1?

C and C++ can run on many different architectures, and machine types. Consequently, they can have different representations of numbers: Two’s complement, and Ones’ complement being the most common. In general you should not rely on a particular representation in your program. For unsigned integer types (size_t being one of those), the C standard (and the … Read more

How to track down a “double free or corruption” error

If you’re using glibc, you can set the MALLOC_CHECK_ environment variable to 2, this will cause glibc to use an error tolerant version of malloc, which will cause your program to abort at the point where the double free is done. You can set this from gdb by using the set environment MALLOC_CHECK_ 2 command before running your program; the program … Read more

Strings and character with printf

If you try this: Output is: So ‘name’ is actually a pointer to the array of characters in memory. If you try reading the first four bytes at 0xbff5391b, you will see ‘s’, ‘i’, ‘v’ and ‘a’ To print a character you need to pass the value of the character to printf. The value can … Read more

C: correct usage of strtok_r

The documentation for strtok_r is quite clear. The strtok_r() function is a reentrant version strtok(). The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string. On the first call to strtok_r(), str should point to the string … Read more

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