Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 30th, 2006, 3:51 PM   #1
Fall Back Son
Professional Programmer
 
Join Date: Oct 2006
Posts: 311
Rep Power: 3 Fall Back Son is on a distinguished road
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)
Fall Back Son is offline   Reply With Quote
Old Oct 30th, 2006, 4:12 PM   #2
Fall Back Son
Professional Programmer
 
Join Date: Oct 2006
Posts: 311
Rep Power: 3 Fall Back Son is on a distinguished road
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
Fall Back Son is offline   Reply With Quote
Old Oct 30th, 2006, 5:10 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC