← Back to topics
Topic

Piping

a
amuts09
Hi, i whant my own tester(to know if my solution passes some simple tests before i submit it)
i found out that piping could be good enough:
[c="c++"]
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <string>
#include <sstream>
#include <iostream>
#include <direct.h>
using namespace std;

int main()
{
FILE *fp = popen("test.exe", "r+t" );
char buff[32];
char command[32];

while (fp != NULL)
{
while ( fgets( buff, sizeof buff, fp ) != NULL )
{
cout << buff;
}
cin.getline(command, sizeof command);
fputs(command, fp);
}
pclose( fp );

getch();

}
[\c], but unfortinately, it doesn't work :(