Featured Post

write pipe with open


#include
int main(int argc,char *argv[])
{
FILE *popen_fp,*infile;
char readbuf[80];
if(argc!=3)
{
fprintf(stderr, "valid : open3 command filename \n");
}

if((infile=fopen(argv[2],"rt")) == NULL )
{
perror("open failue!");
exit(1);
}
if(( popen_fp=popen(argv[1],"w")) ==NULL)
{
perror("popen failure");
exit(1);
}

do{

fgets(readbuf,80,infile);
if(feof(infile))
break;
fputs(readbuf,popen_fp);
} while(!feof(infile));

fclose(infile);
pclose(popen_fp);

exit(0);
}

Comments

Popular posts from this blog

[Inside AdSense] Understanding your eCPM (effective cost per thousand impress...