#include <stdio.h>
int main()
{
char temp[1024];
if(getchar() != 'y')
{
printf("no options\n");
return 1;
}
scanf(temp, "%s");
printf("%s", temp);
}
I get snippet as below. I just want twice input from user. but the first input works, however the second directly skips and the printf("%s", temp); printed unexpected characters. How can I resolve the problem..
thanx
The first parameter to
scanfis the format, and the second is the buffer. You have it backwards. Tryscanf( "%s", temp );.