What does "char * removeSpace(char * input, char * output)"
do? |
If you mean line 4, it's the declaration of the prototype of the function. It is there so that when the compiler sees the function call at line 27, it knows enough about the function to be able to generate code.
In some larger programs, the full definition of the function might be in a completely separate file. In this case it's just a few lines lower down, but the principle is the same.
Im still confuse about why wont my gets(); work in the code i shown above |
Well, when you use scanf to enter a number, what do you actually type on the keyboard? You type some digits, and then press enter. All of those keystrokes are stored as characters in the input buffer (an area of memory set aside for that purpose). So the buffer contains something like "2\n".
Next the scanf routine examines what it finds in the buffer and tries to get an integer. As soon as the newline character '\n' is encountered, it isn't part of the number, so scanf stops at that point, and the newline remains in the buffer.
Later, when you try to do gets(), the routine finds the newline character in the buffer, and considers that to be the end of the string.
You can demonstrate this for yourself. At the menu screen, instead of entering "2", try entering some text as well, like this, "2 hello". You should find that the gets() function will receive " hello".