Hi,
I have asked this question before but a seam to not understand how it works. So if someone would be so kind to give an example. So what i have is this peace of code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
FILE *fp;
char buff[91];
int x,y,c;
fp = fopen(argv[1], "r");
while (fgets(buff, 10, fp) != NULL) {
if (buff[0] == '-'){
printf("%s",buff);
}
else if (buff[0] == '\n'){
continue;
}
else if ((c=sscanf (buff,"%d %d", &x, &y)) !=0){
printf("%d,%d\n",x,y);
}
}
fclose(fp);
return 0;
}
so what it does is it reads some file extracts some info and so on. Also here is the input file.
Code:
-first set
23 22
32 22
23 22
-second set
54 44
34 33
23 45
23 45
and this input is saved in file called in.txt
the way i run the program now is : ./prog in.txt
but i would like to run it like: cat in.txt | ./prog
so pipe it from stdout of cat how do i do this ??
baxy