This is weird, I make a program so that you can place characters anywhere in the console, then you can save it. But, when it writes the characters coords to a file, it just writes the same coord over and over and over. (Four times) I used stringstreams, which I have had basicaly no practice with.
Heres my save code:
TE and TD each hold the character information, which is collected elsewhere. I'm pritty confident that I coded there positions correctly, however if nothing here is amiss I can post the code that gathers them... But its pritty long, and quite ugly. I have a feeling I didint use stringstreams proporely. But I've only used them once or twice before, so I'm really unsure how to use them. (Do I need to clear them before I can add new data or something?) The file itself is written without any problem though.Code://at confirm int ATCONFIRM() { int x; ClearAsyncArrowBuffer(); //This just checks if any arrows are down and returns nothing //It just clears the arrow buffer, which I had trouble with before using this to clear it. for(x=0; x <= 200; x++) if(GetAsyncKeyState(VK_LEFT)&SHRT_MAX) return 1; else Sleep(10); return 0; } int Save() { string info; string PATH; stringstream ss; int I = 0; if(!ATCONFIRM()) return 0; PATH="C:\\"; //Saves to c drive. PATH+=Ext[0]; //Ext is a global char-variable. PATH+=".bsf"; //Openable as a text file in notepad. ofstream file_out(PATH.c_str()); if(!file_out) { MessageBox(NULL, "Error[2], could not open file!", "Error[2]", MB_OK); return -1; } ss << TE[I].X; ss >> info; file_out << info; ss << TE[I].Y; ss >> info; file_out << info; ss << TD[I].X; ss >> info; file_out << info; ss << TD[I].Y; ss >> info; file_out << info; file_out.close(); MessageBox(NULL, "File Saved Successfuly.", "Sucess!", MB_OK); return 1; }
Thanks for your time!.



LinkBack URL
About LinkBacks
. 


