作者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