-
reading from stdin
Hi,
I'm trying to use a software at:ftp://ftp.toulouse.inra.fr/pub/multalin.
The software takes a file as input. But what I want to do is make it read from stdin so that each time I want to run it I don't have to create a text file and feed it in!That kills disk space and also its an IO read. I've got the .c code. But I don't know exactly how to make it read from stdin. Any suggestions on this?
Also, if there are no means to make it read from stdin are there any means to create some "virtual file" in C?
Thank,
Angkar
-
Can you show the section of the program that does the file I/O operations?
-
The program might already support passing "-" for the filename to read from stdin; most Linux programs do.
Otherwise, replace the file stream with "stdin" and get rid of the code that opens and closes the file (search for "fopen" and "fclose").
-
you mean something like scanf?
-
Yes, replace calls to fscanf(fp, "%i", &i) with fscanf(stdin, "%i", &i) or the equivalent scanf("%i", &i).