Beginner with C: Problem with textual files

Hello,
I'm trying to write a program for my assignment. I'm using STRUCTS and fprintf for writing in a file. Problem: I have main screen with choices, like, create (text file with student info), append / add - (not yet started working on it), delete student(s) - (not yet started working on it) and list students from certain file - (not yet started working on it). In create, I'm passing a size of STRUCT array to function, and in function, everything works, but I can't seem to implement anything that will check if the file already exists. I'm using fgets for user input for file name and I'd really appreciate if someone could help me around checking problem. I've tried access one, it either gives me "File exists!" all the time, or lets me in loop and then breaks after 1st input (even tho I don't have any break in loop).

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

No, I did not. I haven't gotten any errors. I'm using Visual Studio 2019. And I do check for errors and warning messages. The only warning message I got was that types differ, since fopen returns int and I'm checking with FILE* pointer. So, as I said, still a beginner, still not sure how things should or do work. Thank you for your tips.

No, I did not. I haven't gotten any errors. I'm using Visual Studio 2019. And I do check for errors and warning messages. The only warning message I got was that types differ, since fopen returns int and I'm checking with FILE* pointer.

fopen returns a FILE*, not an int: the int is because the result of fopen("foo","r") == NULL is an int. That warning message is exactly what Salem was talking about.

Originally Posted by Bjarne Stroustrup (2000-10-14)

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

I've tried changing it and it was as Salem said. Well, I'm still learning, and our courses are going slowly. We haven't had any proper assignments yet, so I'm "winging" it on my own. Thank you for your help!