Member Avatar

I just started on SPOJ. It tests by redirecting standard input and output to files. Is there a way to do that directly from the terminal instead of modifying the program.

Recommended Answers

If your on linux you can use the '<' operator. As in ./app < fileName it gets the input from the file instead of direct terminal.

Jump to Post

All 4 Replies

If your on linux you can use the '<' operator. As in ./app < fileName it gets the input from the file instead of direct terminal.

Member Avatar

If your on linux you can use the '<' operator. As in ./app < fileName it gets the input from the file instead of direct terminal.

So after compiling should i use ./a.out < filename ?
What about output?

If you want to redirect the output from terminal you use the '>' operator to a file. As in ./app < inputFile > outputFile

Member Avatar

Thanks for answering

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.