Need help with programming lab.

This is a discussion on Need help with programming lab. within the C++ Programming forums, part of the General Programming Boards category; Hello all. I am working on a programming 2 lab and am unsure how to code the input and output ...

  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,183

  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, 12:24 PM
  2. Datastructure lab
    By El_Maco in forum C++ Programming
    Replies: 14
    Last Post: 10-10-2004, 08:35 AM
  3. programming from home to the lab???
    By nbo10 in forum Tech Board
    Replies: 7
    Last Post: 08-27-2004, 05: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, 07:53 PM

Tags for this Thread


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