Jag har följande C-kod:Adressen i c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char *str;
/* Initial memory allocation */
str = (char *) malloc(15);
strcpy(str, "tutorialspoint");
printf("String = %s, Address = %u\n", str, str);
free(str);
return 0;
}
Men får följande felmeddelande, dvs adressen går inte att få fram,
Hur åtgärdar detta compilatorfel?
C Online Compiler [gcc-5.1]
Copyright (c) Free Software Foundation, Inc.
Compiling your program...
prog.c: In function ‘main’:
prog.c:12:37: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘char *’ [-Werror=format=]
printf("String = %s, Address = %u\n", str, str);
^
cc1: all warnings being treated