Yes, I used popen(). But there is problem, i don't know why ?
I create new project use Microsoft VC++, create class Example.c
this code run very wellCode:#include <stdlib.h> #include <stdio.h> main(){ FILE *fp; char line[200]; fp = _popen("java -version 2>&1","r"); if(fp == NULL) { exit(1); } while(!feof(fp)) { if(fgets(line, sizeof line, fp)) { printf("%s", line); } } _pclose(fp); }
But I copy this part:
paste in to main() method of other project, when run, fp have not result and call exit()Code:FILE *fp; char line[200]; fp = _popen("java -version 2>&1","r"); if(fp == NULL) { exit(1); } while(!feof(fp)) { if(fgets(line, sizeof line, fp)) { printf("%s", line); } } _pclose(fp);
I compile have not error. I don't know why ? I work on Windows environment



LinkBack URL
About LinkBacks



