I know there are hundreds of topics about it, but I need to ask again. I do have the following code:
char *str;
while(fgets(&str,50,stdin) != NULL && &str != EOF) {
printf(&str);
}
printf("Test");
I would like to read several lines in my code and do something with them. In that example it's just printing. I would like to end, when there is an EOF and then do other stuff after the while-loop. Unfortunately, in the moment when I am using CMD-D (EOF on mac/CLion), the complete program terminates, no matter whats afterwords, so there is no "Test" at the output anymore.
Does anyone know whats happening? Also note, that I need it as a char pointer, because I want to work with it later.