MSDN has an article on scanf and how you specify the size: http://msdn2.microsoft.com/en-us/lib...x1(VS.80).aspx
Remember that scanf also stops reading at the first blank space ( ), so if you type something like "Hello World" - it will only read "Hello". Both of these problems can be fixed using fgets.
But wait! There's a third problem with scanf! If scanf encounters some characters it doesn't want to read, it simply leaves them in the buffer - so in the example above with "Hello World", there will still be " World" left in the buffer after scanf returns! That means the next time you call scanf to read something from the user, it will read this " World" and not prompt the user for anything.
Further, even if the user does enter something and scanf reads it, it will usually leave the newline ('\n') in the buffer so the next call to scanf will return immediately just like the above example!
To fix this, usually you would do a loop with getchar until get clear the input buffer of all remaining characters (see examples). Then scanf will behave as expected again.
But you can also just use fgets, which takes an argument for buffer size. Here's documentation for fgets on MSDN: http://msdn2.microsoft.com/en-us/lib...kf(VS.71).aspx
Remember that fgets reads an entire line and also stores the '\n' (the newline) in your buffer.
And lastly, I will differentiate between '\0', 0 and NULL.
Essentially, they all translate to the same thing to the compiler - 0. However, this does NOT mean that you should assign NULL to a character index.
buffer = NULL; /* Bad! */
NULL is used to set pointers to point at 0 only, and with pointers only. Usually, 0 is an guaranteed to be invalid address (at least in Windows), so we typically set pointers to NULL when we don't need them so as to flag them, "these are not valid pointers anymore, don't use them."
With strings, you should preferably use '\0' since it's the actual character for terminating strings. 0 is the same, so it's fine to assign 0, too, but it is recommended to use '\0'.
char buffer = "Hello World!";
buffer = 0; /* Buffer will now be "Hello" */
buffer = ' '; /* Buffer will now be "Hello World!" */
buffer = '\0'; /* Buffer will now be "Hello" */
Take heed also that NULL is defined as ((void*)0) in C since it's supposed to be used with pointers only (it's quite valid in C). Although due to C's poor type safety, it's possible to assign NULL to a character array, though you may get a warning. Right, so the idea is to avoid compiler warnings, so don't do it. The idea with 0, '\0' and NULL are all to avoid confusion. Use them where appropriate or you might confuse someone else how reads your code.
As a last note, NULL is defined as 0 in C++, so it's easier to get away with setting a character array to NULL, but again, don't do it.