Hi, I have a question regarding the popen() function in C.
I would like to open a text file and count the "the" words, and this would do the job:
Now i would like to read the file name,"myfile.txt", from the standard input as a string and pass it to the popen() function.
fin=popen("cat myfile.txt | grep -o -w 'the' |wc -w ","r");
For example i would like to have something like:
Is there any way i could do this?I know this doesn't work because Shell tries to open the file named 'filename'.
fin=popen("cat filename | grep -o -w 'the' |wc -w ","w"))==NULL);