×

# Clubbing a .txt file with a .cpp file

 0 I have a file (.txt) and I have a C++ program based on trie. Now what I need is the search function performs search on data taken form that .txt file. What I should do now to achieve that?? asked 26 Jan '16, 16:09 56●5●21 accept rate: 0%

 1 You can also use a pipe if running from command line without adding anything to your normal C/C++ program. The command is as follows :- (assuming a.out is your program executable) ./a.out < input.txt > output.txt A '>' or '<' defines the direction of data flow from left to right or vice versa respectively. Hence, if you wish to output to terminal and only take input from input.txt, your command will be :- ./a.out < input.txt answered 27 Jan '16, 00:57 3★ankg 211●3 accept rate: 33%
 0 Use freopen function: http://www.cplusplus.com/reference/cstdio/freopen/ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);  To take input from input.txt and output to output.txt answered 26 Jan '16, 18:20 6★vsp4 1.2k●1●3●8 accept rate: 28%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,380
×183
×40
×14

question asked: 26 Jan '16, 16:09

question was seen: 1,083 times

last updated: 27 Jan '16, 00:57