I am trying to write a program where i want to create a file using the id given by the user but is the file already exists then i want my program not to overwrite it but show some message like already exists. how can i do that.
#include<stdio.h>
#include<stdlib.h>
struct student_info{
char fName[10],lName[10],depart[10],student_id[10];
long borrowed_books[5];
};
int main(){
struct student_info student;
FILE *fpt;
printf("enter your id:\n");
scanf("%s",student.student_id);
printf("enter your first name:\n");
scanf("%s",student.fName);
printf("enter your last name:\n");
scanf("%s",student.lName);
printf("enter your department:\n");
scanf("%s",student.depart);
fpt=fopen(student.student_id,"w");
fclose(fpt);
}