I need to code a program in C to read it from stdin redirection (i.e. root@box~# ./a.out < file), my question is, how can i do that?
I've tried with functions like fscanf(stdin, "%s->%s", var1, var2), but it only reads the first line of the file. How do i pass to the next line in file, and how do i detect the EOF?
are you sure you get an output?
the < already open stdin on file,no need to do more to redirection.However,"-->" is NOT a seperator for scanf,you can achieve your goal by this: