Hi,
I have written this function in a C program, using Visual Studio. The
PHP script executes fine, but the output is not displayed. I have
been racking my brains for hours trying to figure this one out. The
output from the php program should print to a file called 'out.txt'.
The file is successfully created, but with no content. I am pretty
sure it's the way PHP returns the results. Does anyone have any
ideas? Any help would be most appreciated.
int passCode(void)
{
FILE *phpFile, *out;
size_t len;
char buffer[1000];
phpFile = popen("php -f testing1.php", "r");
if (phpFile)
{
out = fopen("out.txt", "w");
len = fread(buffer, 1, sizeof(buffer), phpFile);
fprintf(out, buffer);
fclose(out);
pclose(phpFile);
return 1;
}
else
{
return 0;
}
}