作者longted6 (阿德)
看板C_and_CPP
標題[討論] run time error 相關的問題
時間Wed Feb 24 02:16:32 2016
這是我的片段的 code
main 中的 片段 code
int *ans=find(m,n,letter_query);
printf("%d %d\n",ans[0]+1,ans[1]+1);
int *find(int m,int n,char *letter_query)
{
int ans[2]
.....
......
return ans
}
我解uva online jundge 以上是我片段的程式碼 然後 response 是 run time error
但是我把 ans array 宣告成global變數 就AC 為什麼會這樣子 而且我的complier
沒當調 是我丟上去 uva online judge 才 response run time error message
為什麼會這樣子
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.122.100.231
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1456251395.A.78B.html
推 QQ29: 你return了local 變數的address了 "ans" 02/24 02:25
推 boss0405: local變數跳出function就沒了,你回傳的address裡面的資 02/24 12:05
→ boss0405: 料不一定會正確 02/24 12:05