# C語言題庫-005 請問以下代碼有什麼問題: ``` int main() { char a; char *str=&a; strcpy(str,“hello”); printf(str); return 0; } ``` 【標準答案】沒有爲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