Hello,
It seems we can not use popen and pclose functions. They are defined in stdio.h but when compiling one receives the message: undefined function 'popen'.
For example, the follwing simple code does not compile.
int MAXSTRS =5;
int main(void)
{
int cntr;
FILE *pipe_fp;
char *strings[MAXSTRS] = { "echo", "bravo", "alpha",
"charlie", "delta"};
/* Create one way pipe line with call to popen() */
if (( pipe_fp = popen("sort", "w")) == NULL)
{
perror("popen");
return 1;
}
/* Processing loop */
for(cntr=0; cntr<MAXSTRS; cntr++) {
fputs(strings[cntr], pipe_fp);
fputc('\n', pipe_fp);
}
/* Close the pipe */
pclose(pipe_fp);
return(0);
}
Any idea to bypass this problem?
Edited 1 time(s). Last edit at 08/17/2013 09:12PM by joaopa.