Hello,
I know that in order to include a whitespace character in a string I need to use a gets() but it I can't input any charaters in before the program moves onto the next command asking for a an integer where I use a scanf to read that. Why does this happen and how can I fix it?
Thanks,
Vireyda
Code:printf("\nPlease enter the following information:"); printf("\nEmployee %d Name: ", i); gets(expenses[i].employee_name); printf("\nEmployee Number: "); scanf("%d", &expenses[i].emp_num);



LinkBack URL
About LinkBacks



Also note that cin's >> operator works in much the same way as scanf, so you'll have similar problems. It's better to read all of your input as a string with fgets/getline and then extract the data you want with sscanf.