Re: [問題] 字串回傳被腰斬
今天上程式語言教到這個問題
老師說
int a[20]; 是 call stack
int *a = new int[20]; 是 key
所以 stack 在 return 時會不見
老實說這個講法有點奇怪......
※ 引述《iWRZ ()》之銘言:
: 開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
: netbeans
: G++ 4.3
: 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
: 問題(Question):
: return 字串時只印到第8字元
: 後面全部都不見
: 餵入的資料(Input):
: (直接寫在程式上)
: 預期的正確結果(Expected Output):
: 477265656E20
: 477265656E20
: 錯誤結果(Wrong Output):
: 477265656E20
: 47726565
: 程式碼(Code):(請善用置底文網頁, 記得排版)
: http://ideone.com/ncooW
: 補充說明(Supplement):
: 以前寫function回傳最常回傳 int, bool, 自訂義型別指標
: 第一次寫回傳字串......
: 拜託鞭小力一點
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.135.250.184
→
04/12 13:43, , 1F
04/12 13:43, 1F
→
04/12 17:44, , 2F
04/12 17:44, 2F
→
04/12 17:48, , 3F
04/12 17:48, 3F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章