The reason you declare main as returning an int is that all programs return status codes to the operating system - especially in Unix/Linux. By convention, returning zero means everything went ok.
I generally recommend avoiding any calls to scanf() directly. Instead, read the string in and perform sscanf() on the string. scanf() skips whitespace in ways that can be confusing.
-Hak Ron