它一定很简单,但我现在很麻木,想清楚。 所以这是我的代码的一小部分一切正常,除了这一点。 我真正想要做的是infile1.open(temp2-> path);但这是不可能的,因为temp2是一个字符串。所以我想把这个字符串放入像char p [100]这样的字符数组来使用infile1.open(p)。它编译但经过几秒钟的繁荣:围绕p堆栈被损坏围绕p堆栈被损坏C++
char p[100];
while(temp2 != 0)
{
stringToCharArray(temp2->path, p);
infile1.open(p);
checkingWords(infile1, stopWords, invertedIndex);
infile1.close();
temp2 = temp2->next;
}
void stringToCharArray(string s, char *c)
{
int i;
int size = s.size();
for(i=0; i<=size ; i++)
{
c[i] = s[i];
}
}
您没有终止。你的路径是否超过99个字符? –