After foraging about here and there, I found a way to run a subprocess from my program (if that's the right way to call it).
All in all, it runs the way I want it to, but there's a slight tick with it that I want to get rid of.
If I want to display the output from the subprocess, I can't write to it, but if I write to it, I can't get output from it.
Here's the offending line of code:
Code:
if( (pPipe = _popen( "xfst", "wr" )) == NULL )
exit( 1 );
If I change the ordering of the second argument in _popen to "rw", I can't pass input to it. It's fine the way it is right now, but I would like to see what's going on, while I'm at it.
Here's the entire body of the code:
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
char psBuffer[128];
FILE *pPipe;
if( (pPipe = _popen( "xfst", "wr" )) == NULL )
exit( 1 );
while( !strcmp("\n", psBuffer))
{
if( fgets( psBuffer, 128, pPipe ) != NULL )
printf( psBuffer );
}
fprintf(pPipe, "define A [a|b]*;");
fprintf(pPipe, "exit\n");
printf( "\nProcess returned %d\n", _pclose( pPipe ) );
system("pause");
return 0;
}