So what 2>&1 does is redirect the output of stderr (being 2) to the stdout (being 1) ?
Is there also a way to check when it is done compiling before I execute the _pclose() function ?
Yes.
Sorry, just saw the second part.
Check your file pointer against feof(test) before using it. Something like:
while( !feof(test) )
{
...
}