The following code works fine if run from the main but the SAME code will not function at all from a subroutine. It is designed to read input from the keyboard and assign it to a char string. If I run it from the subroutine (insertString listed below), it does not pause to ask for input, but just keeps going to the next line of code. This does not happen if run from main. Do you know why it only works in the main, and is this just a restriction of C?

[code]
void insertString (void);

/*WORKS FINE FROM MAIN*/
int main (void) {
char sourceString[100];
printf ("\n\tEnter a Source String: ");
fgets (sourceString, sizeof (sourceString), stdin);
printf ("\nSource String is %s", sourceString);
system("pause");
return 0;
}

/* NOT WORK FOR SUBROUTINE*/
void insertString (void) {
char sourceString[100];

printf ("\n\tEnter a Source String: ");

fgets (sourceString, sizeof (sourceString), stdin);

printf ("\nSource String is %s", sourceString);

} /* end function insertString */
[code]