[問題] c_str未宣告???

看板C_and_CPP (C/C++)作者 (內褲魔)時間16年前 (2009/03/15 23:09), 編輯推噓3(307)
留言10則, 5人參與, 最新討論串1/1
現在想要把一個string轉成int 找了一下決定用一下的方法 int temp=atoi(code.c_str()); 有include string這個檔案了 可是在編譯的時候跑出'c_str' has not been declared request for member of non-aggregate type before '(' token 請問一下我是少include什麼檔案嗎  貼上比較完整的 int i; string **codenumber = new string*[26000];//指定二維陣列 for( int i=0 ; i <26000 ; i++ ) {codenumber[i]=new string[1];} while(!inStream.eof()) { int temp=atoi(*codenumber[i].c_str());//此行一直有問題 i++; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.208.33.70

03/15 23:12, , 1F
using namespace std; 有加了嗎?
03/15 23:12, 1F

03/15 23:26, , 2F
03/15 23:26, 2F

03/15 23:38, , 3F
include<cstring>?
03/15 23:38, 3F

03/15 23:42, , 4F
是說 我都不用include 就可以跑ㄝ
03/15 23:42, 4F

03/15 23:48, , 5F
剛剛另外測了一下 c_str()使用正常 可是原本的檔案還是不
03/15 23:48, 5F

03/15 23:48, , 6F
行 
03/15 23:48, 6F
※ 編輯: cophie 來自: 134.208.33.70 (03/15 23:53) ※ 編輯: cophie 來自: 134.208.33.70 (03/15 23:54)

03/16 00:06, , 7F
codenumber[i]->c_str()
03/16 00:06, 7F

03/16 00:07, , 8F
Why not vector?
03/16 00:07, 8F

03/16 00:28, , 9F
感謝樓上 問題已解決
03/16 00:28, 9F

03/16 16:55, , 10F
..不是cstring 是<string>
03/16 16:55, 10F
文章代碼(AID): #19lHevQP (C_and_CPP)
文章代碼(AID): #19lHevQP (C_and_CPP)