This question already has an answer here:
- Reading Console Buffer / Output C++ 1 answer
I want to create a simple handler for my game server. It will read the console directly and take any action i want. BUT! I can't pass the output from the server to my exe or txt.
ping google.com > ping.log
It works fine, everything will be logged in my log file. Also I created an exe, that can read the output data this way:
ping google.com | my.exe
It also works fine, my exe's content is:
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
string input = "";
while(cin) {
getline(cin, input);
cout << input << endl;
};
system("pause");
}
It shows everything line by line.
The problem is with the jampded.exe. If I start it with a batch file, it has output in the console window, but I can not pass this for my log file, or my.exe. I have no idea.
I put cout-s in my code, so it shows it is stucking in the while loop. getline waits for cin, but nothing passed.. But why?