看板 C_and_CPP 關於我們 聯絡資訊
這是我的片段的 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