php - Execute & store result from command in C -
i'm trying test php file c program(...)
basically have filename want check against php -l , store output further processing.
a simple solution in case redirect output file. , read file array. can have further processing array.
something this(in c):
system("php -l yourfile.php > myfile"); file *f = fopen("myfile", "rb"); fseek(f, 0, seek_end); long pos = ftell(f); fseek(f, 0, seek_set); char *array = malloc(pos); fread(array, pos, 1, f); fclose(f); //your processing part here.. free(array); // free allocated memory
solution #2: invoke php interpreter, , pipe output program. following in console:
php -l yourfile.php | pathtoyourcprogram
in above case, read output of php stdin. can read entire input, , directly store array.
Comments
Post a Comment