I should mention that this does work in a different environment: in our programming class we normally use the IDE codeblocks (which is find awful), so I just use the gcc compiler and vim in my terminal (I'm on arch). I didn't encounter problems until recently, when I had to read in a string which contained spaces. For that I thought using the fgets()
function would be a good idea, but it created some problems. This is what the code looks like:
void addStudent() {
struct Student student;
printf("Name of student: ");
fgets(student.name, 25, stdin);
}
This however does not prompt me for input in my shell, it simply continues and reads in a newline character \n
immediately. Do you guys have any idea how to fix this?