作者cophie (內褲魔)
看板C_and_CPP
標題[問題] c_str未宣告???
時間Sun Mar 15 23:09:44 2009
現在想要把一個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
1F:→ james732:using namespace std; 有加了嗎? 03/15 23:12
2F:→ cophie:有 03/15 23:26
3F:推 lytn:include<cstring>? 03/15 23:38
4F:→ lytn:是說 我都不用include 就可以跑ㄝ 03/15 23:42
5F:→ cophie:剛剛另外測了一下 c_str()使用正常 可是原本的檔案還是不 03/15 23:48
6F:→ cophie:行 03/15 23:48
※ 編輯: cophie 來自: 134.208.33.70 (03/15 23:53)
※ 編輯: cophie 來自: 134.208.33.70 (03/15 23:54)
7F:推 legnaleurc:codenumber[i]->c_str() 03/16 00:06
8F:→ legnaleurc:Why not vector? 03/16 00:07
9F:→ cophie:感謝樓上 問題已解決 03/16 00:28
10F:推 Killercat:..不是cstring 是<string> 03/16 16:55