#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
FILE *fp;
int status;
char output[1024];
/* Open the command for reading. */
//popen调用本地php,执行php代码获取返回值并输出
fp = popen("/usr/bin/php /Users/Bear/webroot/xinnet/index.php /cron/learning/s", "r");
if (fp == NULL) {
printf("Foobar!\n" );
return 0;
}
/* Read the output a line at a time - output it. */
while (fgets(output, sizeof(output)-1, fp) != NULL) {
//do whatever
puts(output);
}
/* close */
pclose(fp);
return 0;
}