具体来说,抛出malloc的结果有什么危险?
malloc
#include <string.h>#include <stdio.h>// #include <stdlib.h>int main(int argc, char** argv) { char * p = /*(char*)*/malloc(10); strcpy(p, "hello"); printf("%s\n", p); return 0;}
anon@anon:~/$ gcc -Wextra nostdlib_malloc.c -o nostdlib_malloc nostdlib_malloc.c: In function ‘main’:nostdlib_malloc.c:7: warning: incompatible implicit declaration of built-in function ‘malloc’anon@anon:~/$ ./nostdlib_malloc hello
malloc
编辑
MMMHUHU
莫回无
慕村9548890
相关分类