|
首先代码没毛病。。。
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;
} |
|