Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C: Affichage un message d’erreur avec ‘perror’


{filelink=13138}

/*
void perror ( const char *string  );
 
*/ 
 
  #include <stdio.h>
  #include <stdlib.h>
 
  FILE *fp;
  char msgbuf[256] = "";
 
  int main(char argv[])
  {
    if (( fp = fopen( "fichier_inconnu", "r" )) == NULL )
	{
		sprintf( msgbuf, 256, "%s, function %s, file %s, line %d",
            argv[0], __func__, __FILE__, __LINE__ );
           perror( msgbuf );
	}
return 0;
  }

No comments yet.

Leave a Comment