Using the C ANSI language, I am trying to pass main
's argv
parameter into a function that will print a msg
in stderr
.
Here is the function signature :
void erreur(Erreur_prog erreur_entree, const char **argv);
Here is the function :
void erreur(Erreur_prog erreur_entree, const char **argv)
{
switch (erreur_entree)
{
case status_ok:
fprintf(stderr, "%s : Le status est ok.\n", argv[0]);
exit(0);
break;
case fichier_pgm_manquant:
fprintf(stderr, "%s : Le fichier PGM est manquant.\n", argv[0]);
exit(fichier_pgm_manquant);
break;
default:
fprintf(stderr, "%s : Erreur.\n", argv[0]);
}
}
I keep on getting this type of error :
tp2.c:139:33: attention : passing argument 2 of ‘erreur’ from incompatible pointer type
erreur(arguments_invalide, argv);
^
tp2.c:55:6: note: expected ‘const char **’ but argument is of type ‘char **’
void erreur(Erreur_prog erreur_entree, const char **argv);
Here's an example of the call :
erreur(arguments_invalide, argv);
I tryed playing around with the pointers but ... there's something i'm not getting.
Anyone can point me out what i'm missing out ?