VS2010这算是什么怪异的现象??
首先代码没毛病。。。int WinMain(__in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd)
{
fstream file;
string str;
file.open("test.txt");
strstream buffer;
int offsetg = file.tellg();
int offsetp = file.tellp();
int filelen;
if (offsetg == -1)
{
FILE* fp = fopen("test.txt", "w");
fclose(fp);
file.open("test.txt");
}
AllocConsole();
SetConsoleTitleA("Debug Window");
freopen("CONOUT$","w+t",stdout);
freopen("CONIN$","r+t",stdin);
buffer << "buffer!!!\ndddd";
cout << buffer.str() << endl << "---------" << endl;Sleep(1000);
buffer >> str;
cout << str << endl << "---------" << endl;Sleep(1000);
cout << buffer.str() << endl << "---------" << endl;Sleep(1000);
buffer >> str;
cout << str << endl << "---------" << endl;Sleep(1000);
file << str << endl;file.flush();
for (int i = 0; i < 1000000; i++)
{
cout<<"123455566778\n";
Sleep(100000);
}
file.close();
FreeConsole();
return 0;
} 问题开始。。。
一开始好好的,没问题,后来自己改了改,出问题了,我就把代码改回来了。。然后调试 蹦出个0xC0000095,我就郁闷了,明明都改回原来的样子了。。。
开始做实验
/*
buffer << "buffer!!!\\ndddd";
cout << buffer.str() << endl << "---------" << endl;Sleep(1000);
buffer >> str;
cout << str << endl << "---------" << endl;Sleep(1000);
cout << buffer.str() << endl << "---------" << endl;Sleep(1000);
buffer >> str;
cout << str << endl << "---------" << endl;Sleep(1000);
file << str << endl;file.flush();
*/
看到了吧,这段代码加注释,运行没问题。。。然后一行一行的从注释里面拿出来,调试。。。都没毛病。。。
最后
buffer << "buffer!!!\\ndddd";
cout << buffer.str() << endl << "---------" << endl;Sleep(1000);
buffer >> str;
cout << str << endl << "---------" << endl;Sleep(1000);
cout << buffer.str() << endl << "---------" << endl;Sleep(1000);
buffer >> str;
cout << str << endl << "---------" << endl;Sleep(1000);
file << str << endl;file.flush();
/×
×/
都改成这样了调试,我擦,有没毛病了。。。这个过程中,我绝对没有更改代码,除了一行一行的从注释里面拿出来,每拿一行调试一次。
结果,这代码还是原来的代码 没问题。。。
这VS2010是不是哪抽风了? 是不是应该重新编译一下呢? 谁知道呢,这么长时间了。。。OTZ
页:
[1]