scanning in character string
I have a question in regards to scanning in a character array with spaces for a project im working on for an introductory class in C programming.
I know that I cant use the scanf function becasue it will stop scanning in the characters once it sees a space. Our teacher told us to use the "gets" function.
The string can have a maxium length of 50 characters. So I defined the string variable as
to leave an extra space for the the \0
I can get the gets function to work in an easy case
printf("Enter the string:");
it works fine for this. This is probally a dumb question, but will the gets function be skipped, if it is inside a loop. My program just seems to skip right over the gets function, but if I replace it with a scanf function everything works fine(except for the fact that I cant scan in more than one word).
Here is the basic structure of the part of the program that I am having trouble with.
#define SIZE 50
int selection(void); //prototype of function that chooses encryption method
printf("Enter the string now: ");
printf("Chose method 1-5 by entering integer, ect.")
correct while loop while quit
while loop will continue
In this case, the program doesnt stop and give the user a chance to input a string like it did in the first example.
any help would be appreciated