C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-07-2008, 09:31 PM   #1
Registered User
 
Join Date: Sep 2008
Posts: 2
Need help with programming lab.

Hello all.

I am working on a programming 2 lab and am unsure how to code the input and output for this assignment. Here is what the lab sheet says:

"Your program will be expected to read input from the first file specified on the command line and to write output to the second file specified on the command line. Your program should display an error message and exit immediately if the expected command-line parameters are not provided. Following is an example of how your program will be run from the command line:
$ ./main input.txt output.txt
Your program will continue reading and processing commands from the input file until the end of the file is reached. After processing each command, your program should write the result to the output file. All input and output should use C++ streams (>> and <<).
For this lab, strings may be stored in static-sized character arrays. You can assume that your program will not be tested with any strings longer than 100 characters, and all strings will be separated by whitespace. "

With this criteria i am unsure on how to write my main function. Any help would be appreciated.
woody292 is offline   Reply With Quote
Old 09-07-2008, 10:06 PM   #2
Registered User
 
Join Date: Jan 2008
Posts: 66
Use command line arguments in your main function like this.

int main(int argc, char *argv[])

Then check of there is a parameter specified.
ThLstN is offline   Reply With Quote
Old 09-07-2008, 10:44 PM   #3
Registered User
 
Join Date: Dec 2006
Posts: 1,780
http://cboard.cprogramming.com/annou...t.php?f=3&a=39
cyberfish is offline   Reply With Quote
Old 09-07-2008, 11:19 PM   #4
Registered User
 
Join Date: Sep 2008
Posts: 2
Quote:
Originally Posted by cyberfish View Post
Thank you for pointing me to that thread.
woody292 is offline   Reply With Quote
Reply

Tags
input, output

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lab exam hawkins786 C Programming 11 05-24-2005 11:24 AM
Datastructure lab El_Maco C++ Programming 14 10-10-2004 07:35 AM
programming from home to the lab??? nbo10 Tech Board 7 08-27-2004 04:35 PM
Please help debug this lab! Please! mack_ol C Programming 0 02-17-2002 12:32 PM
stupid computer lab lady... dirkduck A Brief History of Cprogramming.com 7 10-16-2001 06:53 PM


All times are GMT -6. The time now is 05:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22