in C, cannot read string created by malloc : I have a function which receive a pointer of char array as an argument(char** messageErreur). That pointer is created in the main, but no memory is allocated, as it is created only if necessary (error message to display) (no choice here, the method comes from an unchangeable .h file).

here is the code where I get segmentation fault:


    imageMsgErr (messageErreur, "error message");
	printf("erreur1 P2\n");
	printf("message erreur %s\n", *messageErreur); //**where i get the seg fault


    void imageMsgErr (char** messageErreur, char* msg){
	
	    messageErreur= (char**)malloc(sizeof(char*));
	    messageErreur[0]= (char*)malloc(sizeof (char) * 100);

	    if (*messageErreur){
		    printf("before strcpy\n");
		    strcpy(*messageErreur, msg);
		    printf("message erreur %s\n", *messageErreur);
	    }
	    return;

I have tried several similar code with the same result: segmentation fault when it execute the line: printf("message erreur %s\n", *messageErreur);

Help!!!
 
