Also mention sizeof().
Code:
char buffer[10];
fgets(buffer, sizeof(buffer), stdin);
or (works on variables only, not on types like int)
Code:
char buffer[10];
fgets(buffer, sizeof buffer, stdin);
and
Code:
char buffer[10];
scanf("%*[^\n]", sizeof(buffer)-1, buffer);
Just a thought.
You should also mention something about the various methods of stripping newlines from strings. Here are some examples to get you started.
Code:
#include <string.h>
char buffer[] = "Hello, World!\n", *p;
size_t len;
if((p = strchr(buffer, '\n'))) *p = 0;
if((p = strrchr(buffer, '\n'))) *p = 0;
buffer[strcspn(buffer, "\n")] = 0;
len = strlen(buffer);
if(len && buffer[len-1] == '\n') buffer[len-1] = 0;
while(*s && s != '\n') s ++;
*s = 0;
Might want to mention how 0 and '\0' are the same, and how NULL is different. Something about the difference between char *buffer and char buffer[] wouldn't be amiss, as well using sizeof() on pointers like arrays passed to functions.
Just some thoughts. I might write up a post like that, too. It might be useful for sure.