I'm used to using GNU where you can redirect stdin to a text file using the "<" operator when you run your program.
For example, to run the program with stdin redirected to a file called "input.txt" you would type in the unix console:
myprogram.exe < input.txt
Hell, even window's console can redirect stdin, and it uses the same context!.
How do I do this in Pelles C?
Whenever I run my program, it executes stdin without any redirection, so it tries to read input from the console. And also, there is absolutely NO option anywhere to redirect it (command line arguments in "project options" does nothing).
Before anyone answers, I want to make it clear that I do NOT wish to modify my source code to use fgetf and hard code a text file into the source code, or add a dynamic redirection method to the source code that prompts the user for a file name.
I know the source works fine, and all it needs is to redirect stdin to a text file. There ought to be a way to do this in Pelles C.
If you run that program from commandline, does it work ?
#include <stdio.h>
int main(int argc, char **argv)
{
char buff[500];
while (1) {
if (!fgets(buff, 80, stdin)) break;
printf(buff);
}
return 0;
}
Yes, that program works when I run it via the command line. It even works if I redirect stdin to a text file using "<" as a command line argument.
Example: I type:
test.exe < in.txt
and it prints out all the words in in.txt
What I'm asking is how to redirect the file (saying: "< in.txt") when I run the program in Pelle C's IDE (when I click Project -> Execute).
Note that you can specify "command line arguments" in Project -> Project Options, but they don't work for redirection if you type in "< in.txt"