Created
May 9, 2011 03:12
-
-
Save carlosbrando/961992 to your computer and use it in GitHub Desktop.
Apaga arquivo com dupla verificação.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Verificação dupla antes de apagar. */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
int main(int argc, char const *argv[]) { | |
char str[80]; | |
if (argc != 2) { | |
printf("uso: xerase <nomearq>\n"); | |
exit(1); | |
} | |
printf("apaga %s? (S/N): ", argv[1]); | |
gets(str); | |
if (toupper(*str) == 'S') { | |
if (remove(argv[1])) { | |
printf("O arquivo não pode ser apagado.\n"); | |
exit(1); | |
} | |
} | |
return 0; /* retorna sucesso ao SO */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment