1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| void main(int argc, char *argv)
{
char fileName[256] ;
// Cas où il n'y ai pas de paramètres
if(argc<2) {
printf("Utilisation: '%s [nom du fichier]'.\n", argv[0]) ;
return EXIT_SUCCESS ;
}
// Ouverture avec argv[1]
handFile = fopen(argv[1], "r+") ;
if(handFile==NULL) // Gestion de l'erreur
// Ouverture par copie de argv[1]
sprintf(fileName, "%s", argv[1]) ;
// ou
strcpy(fileName, argv[1]) ; // Il faut inclure <string.h>
handFile = fopen(fileName, "r+") ;
if(handFile==NULL) // Gestion de l'erreur |
Partager