![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Oct 2006
Posts: 311
Rep Power: 3
![]() |
unix redirection
I just have no idea how it's done. what I am trying to do is use a text file as the input values for a program... but I don't really know how that works. If my text file is called fallbackson.dat, I have to use
a.out < fallbackson.dat I understand what it does: it runs my program, using fallbackson.dat as input. but i need to take this into consideration when writing my program. how would I write a program where it would take a value from there and use it where I wanted it to be used? what i mean is - where in the program is it using those input values? (i hope that makes sense) |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Oct 2006
Posts: 311
Rep Power: 3
![]() |
wow, nevermind this whole thread. i was overthinking everything. all it does is enter the numbers in the text file into the program, in the order that they are entered in the text file, into wherever there is a scanf statement or a mathematical operation in the program
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
In case you're interested, basic console input and output is handled by one input stream, STDIN, and two output streams, STDOUT and STDERR. Commands like scanf and gets use STDIN by default, and commands like printf use STDOUT. STDERR is reserved for error messages.
Unix redirection works by feeding a file to the STDIN of a program, or by feeding the STDOUT or STDERR to a file ('>' feeds to STDOUT, and '2>' feeds to STDERR). Also, one can use pipes (using '|') to connect the STDOUT from one application to the STDIN of another. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix commands compatible with Windows? | titaniumdecoy | Bash / Shell Scripting | 7 | Oct 5th, 2006 8:25 AM |
| Lions' Commentary on UNIX 6th Edition, with source code | Mad_guy | Book Reviews | 0 | Sep 24th, 2006 8:06 PM |
| Best Linux or Unix Desktop? | Prm753 | Coder's Corner Lounge | 23 | Apr 8th, 2006 11:17 AM |
| Importing from DLL's on Unix | Kaja Fumei | Existing Project Development | 5 | Jan 9th, 2006 7:35 PM |
| Looking for good UNIX book | titaniumdecoy | Coder's Corner Lounge | 7 | Jan 2nd, 2006 4:31 PM |