# C語言題庫-009 ``` void getmemory(char *p) { p=(char *) malloc(100); strcpy(p,“hello world”); } int main( ) { char *str=NULL; getmemory(str); printf(“%s/n”,str); free(str); return 0; } ``` 會出現什麼問題? 【標準答案】程序崩潰,getmemory中的malloc 不能返回 動態內存,free ()對str操作很危險。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up