I want to be able to delete a file using c++ remove functions but gets does not work in visual studio 2019 and using fget and gets_s ,the program runs but everytime it shows message that file not deleted as i proggrammed, The question is when it will delete .I tried every thing but it doesn't work. There would be solutions but i am a student so plz consider my problem.Here is my code :
#include <iostream>
#include <conio.h>
#include <stdio.h>
int main()
{
int status;
char file_name[59];
cout << "enter name of file to delete:\n ";
gets(file_name);
status = remove(file_name);
if (remove(file_name) == 0) //i wrote if(file_name==0); too but it doesn't work
cout << "file deleted";
else
cout << "file not deleted";
}
I was looking for answers in stack over flow other similar questions but they were too professional to be understand by me plz tell me simple way to delete a file that user wants to delete.