Thread: command-line parameters.

  1. #1
    Registered User
    Join Date
    Oct 2001

    Red face command-line parameters.

    Write a program, invoked with command-line parameters, which reads a file (whose path is specified as the last of 3 command-line parameters), searches for each occurrence of the string given as the first parameter and replaces it with the string given as the second parameter. The program is thus invoked by:

    repa11 <string1> <string2> <file>

    i.e." replace all occurrences of string 1 by string 2 in file" If spaces or other" white space characters are included in either string is to be delimited by double quotation marks.

    I know how to do command-line parameters by ANSI-stardard C.
    But i donot know what it means?

  2. #2
    the Corvetter
    Join Date
    Sep 2001
    The command line args are argc and *argv[]. They work like this:

    argc is the # of args
    *argv[] is the array of strings
    1978 Silver Anniversary Corvette

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    >But i donot know what it means?
    You open the file
    You read each line
    If the line contains string1 then you replace it with string2

    fopen / fclose / fgets / fputs - reading and writing files
    strcpy, strcat, strstr - string handling
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 07-21-2008, 06:04 AM
  2. Parameters quick Question
    By lifeis2evil in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2007, 11:12 PM
  3. function with variable number of parameters
    By mikahell in forum C++ Programming
    Replies: 3
    Last Post: 07-23-2006, 03:35 PM
  4. Additional parameters for operator delete
    By darksaidin in forum C++ Programming
    Replies: 0
    Last Post: 09-21-2003, 11:46 AM
  5. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 03:13 AM