Skip to content

Instantly share code, notes, and snippets.

@carlosbrando
Created May 9, 2011 03:12
Show Gist options
  • Save carlosbrando/961992 to your computer and use it in GitHub Desktop.
Save carlosbrando/961992 to your computer and use it in GitHub Desktop.
Apaga arquivo com dupla verificação.
/* 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