February 21st, 2013, 01:30 AM
I want output in following format:
Enter the full name: Rim John
Please help me my program goes to infinite loop and only prints last name
printf("Enter the full name ");
while(getchar()!=32);//waits for space bar to be pressed
while(ch2 != ' ')
scanf(" %c", &ch2);
February 21st, 2013, 01:57 AM
1. Use [code][/code] tags when posting code.
2. scanf(" %c", &ch2);
Remove the leading space. You're forcing %c to read the next non-space character each time, not the next character.
Also, reading the first name will need more work - but you'll see that soon enough.