Thread: Need help with programming lab.

  1. #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.

  2. #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.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    2
    Thank you for pointing me to that thread.

Popular pages Recent additions subscribe to a feed

Similar Threads

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

Tags for this Thread