What is the difference between %g and %f in C?

See any reference manual, such as the man page: f,F The double argument is rounded and converted to decimal notation in the style [-]ddd.ddd, where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no … Read more

Difference between fgets and fscanf?

The function fgets read until a newline (and also stores it). fscanf with the %s specifier reads until any blank space and doesn’t store it… As a side note, you’re not specifying the size of the buffer in scanf and it’s unsafe. Try:

What exactly is meant by “de-referencing a NULL pointer”?

A NULL pointer points to memory that doesn’t exist. This may be address 0x00000000 or any other implementation-defined value (as long as it can never be a real address). Dereferencing it means trying to access whatever is pointed to by the pointer. The * operator is the dereferencing operator: This is exactly the same thing as a NullReferenceException in C#, except that pointers … Read more

Where is the header file on Linux? Why can’t I find ?

conio.h is a C header file used with old MS-DOS compilers to create text user interfaces. Compilers that target other operating systems, such as Linux-based, 32-bit Windows and OS/2, provide equivalent functionality through other header files and libraries. The #include <curses.h> will give you almost all of the functionality provided by conio.h. “ncurses” needs to be installed in the … Read more

Can I define a function inside a C structure?

No, you cannot define a function within a struct in C. You can have a function pointer in a struct though but having a function pointer is very different from a member function in C++, namely there is no implicit this pointer to the containing struct instance. Contrived example (online demo http://ideone.com/kyHlQ):

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