program wont work, why?

after i put in a name, and press enter, it doesnt pause to let me see the Hello %s!", name the window just closes. ive tried using the void main thing but it wont work on my compiler for some reason. can anyone tell me why this isnt working?

they pause the program until i press enter. i try to use void main with the program and take out the getch()s but then i cant see the program at all, it just comes up for like a second then goes off..i cant enter anything in. so i usually add getch()s to pause my program(and they usually work) but this one isnt working for some reason.

This should make the program do what you want. Dont forget main has to return a value.

You have a missing semicolon, but further, the

Code:

while (getchar() != '\n')
{
getchar();
}

(reformatted for your reading pleasure) both doesn't do what the prompt ("Press any key to continue") says it should (it only exits on return), it also reads two characters each time through, so if the user types "<space><cr>", it will not recognize that as <cr>.

I'm not saying that I think that the use of getchar() is good in general, but if you're going to use it, use it correctly.

As eerok said, you should not silence yourself just because you're not an expert yet. I had not intended to impune you as a person -- you'll only learn by doing, and if you're afraid to make a mistake, you learn very slowly.