Always active warnings. With GCC, use at least -Wall -Wextra -Wstrict-prototypes -Wwrite-strings
.
I/O is difficult. scanf()
is evil. gets()
should never be used.
When you print something which isn't '\n'
-terminated, you have to flush stdout
if you want to print it immediatly, e.g.
printf("Type something: ");
fflush(stdout);
getchar();
Use const
pointers whenever possible. E.g. void foo(const char* p);
.
Use size_t
for storing sizes.
Litteral strings generally can't be modified, so make them const
. E.g. const char* p = "whatever";
.