0
I am doing a job and arrived at a part of removing file that the user wants, but it reads and does not remove. to remove I should use extension (.txt)? if yes, how?
void removeCliente() {
char codigo [50]; int excl;
int *p;
char * file_name;
//FILE* verifica;
printf("entre com o código do cliente que deseja excluir:");
scanf("%s",&codigo);
file_name=codigo;
FILE *fo = fopen(file_name,"r");
if (fo == NULL){
printf("Ocorreu um erro!");
//return 0;
}
else{
fclose(file_name);
fflush(stdin);
remove(file_name);
printf("usuario %d removido com sucesso");
//sleep(10);
}
menugerente();
}
The file name should be exactly the same as the one that exists. If you have an extension, you should put it. And if it’s in another directory, it should have the complete path.
– Kevin Kouketsu
is in the same directory. but how do I put the file extension? if the input name does not have
– Ariani Assunçao
Did my answer solve your problem? If yes, mark it as answered. If not, tell us what is still in doubt. If you don’t know how to mark as a response, take a look at https://answall.com/tour
– Kevin Kouketsu