I'd like to write to a text file such that whenever a user hits a key, the file gets updated with an Ascii character somewhere specific in the file (not appended at the end), and not shown on the screen.
While the following code worked when outputing to the console window, I can't get it to write correctly to a file:
HANDLE hConsole = NULL;
void gotoxy ( int x, int y )
{
COORD c = { x, y };
SetConsoleCursorPosition ( hConsole, c );
}
int main(array<System::String ^> ^args)
{
hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
String^ fileName = "textfile.txt";
StreamWriter^ sw = gcnew StreamWriter(fileName);
gotoxy ( 50, 75 );
sw->WriteLine("This line is not being written to the 50th column,and 75th row");
//Console::WriteLine("This displays at the corrct position");
sw->Close();
return 0;
}
I saw a way of mirroring the console to a log, but is there a way to write to a file without showing on the console? (Mirroring console output to a file)