There are a few questions/issues.
Why is this function calling main()? That's unusual.
When you say it is returning 0, do you mean when the program exits? All programs return 0 unless you specify differently with exit(-2) for example.
I understand that many (especially older) C books use
scanf,
gets and similar functions for console input, or
fscanf,
fgets etc. for file input.
PLEASE PROMISE ME YOU WILL NEVER USE THEM AGAIN.
The reason is what is called a
buffer overflow. Have you ever wondered what would happen if someone typed in
50 characters instead of
20? In a high-level language the input would either be truncated or the name buffer would be resized to accomodate the data. C is a middle-level language, in this case meaning you get more power to control what actually happens in memory. By overfilling your buffer, a user could input machine code, and with some manipulation could execute their code.
If you look at about 75% of all security vulnerabilities in the last 15 years, they are due to buffer overflow exploits just like this.
I realize this is just a little program for learning, but please heed my advice as a programmer of 23 years to break this habit now. At a minimum, change this line to:
scanf ("%20s", name);
Even better,
read about the safe version of these functions, which require that you specify the size of the buffer.