C 语言的几个警告

hello.c: In function ‘get_chars’:
hello.c:26:22: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default]
     char *s = (char*)malloc(sizeof(char) * ( strlen(hello)+ 1));
                      ^ 



添加 #include<stdlib.h>



hello.c:17:15: warning: initialization discards ‘const’ qualifier from pointer target type [enabled by default]
     char *b = get_string();
               ^
hello.c: In function ‘get_chars’:



将 char*b = get_string()  更该为  char const *b = get_string(); 后警告没有了



你可能感兴趣的:(C 语言的几个警告)