We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,763 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Redirecting input and output streams

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.

2
Contributors
4
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
v3ga
Junior Poster in Training
95 posts since Oct 2011
Reputation Points: 14
Solved Threads: 5
Skill Endorsements: 0

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

firstPerson
Industrious Poster
4,044 posts since Dec 2008
Reputation Points: 851
Solved Threads: 625
Skill Endorsements: 14

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?

v3ga
Junior Poster in Training
95 posts since Oct 2011
Reputation Points: 14
Solved Threads: 5
Skill Endorsements: 0

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

firstPerson
Industrious Poster
4,044 posts since Dec 2008
Reputation Points: 851
Solved Threads: 625
Skill Endorsements: 14

Thanks for answering

v3ga
Junior Poster in Training
95 posts since Oct 2011
Reputation Points: 14
Solved Threads: 5
Skill Endorsements: 0
Question Answered as of 1 Year Ago by firstPerson

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0776 seconds using 2.8MB