Results 1 to 6 of 6

Thread: Command Line Arguement

  1. #1
    Senior Member codenamevirus's Avatar
    Join Date
    Jun 2005
    Location
    Faridabad, Haryana, India
    Posts
    298

    Command Line Arguement

    hi

    I m creating a C++ program in Visual C++ 6.0 based on file handling!!

    What I want to do is, I want the user to mention the file name during the command line thing!!

    i..e if the user types: cl problem1 history.txt

    My program opens the history.txt file in reading mode.

    The thing is how do I, take this filename as arguement in my program!!

    thnx
    CodeNameVirus

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Search your help files for ARGV and ARGC... That'll point your nose in the right direction
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    Senior Member codenamevirus's Avatar
    Join Date
    Jun 2005
    Location
    Faridabad, Haryana, India
    Posts
    298
    hi SirDice

    thnx for putting me on the right direction!!

    Now, I have created a C++ program in Visual C++ 6.0.

    Can u tell me the exact steps that I need to take, so as to be able to execute my program thru the command line.

    Thnx
    CodeNameVirus

  4. #4
    Ninja Code Monkey
    Join Date
    Nov 2001
    Location
    Washington State
    Posts
    1,027
    Step 1 - Learn to use google
    Step 2 - Learn C++

    Parsing out arguments given via the command line is usually one of the first few chapters of any book on c++ programming. Finding a tutorial on doing it should be trivial via google.
    "When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
    "There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
    "Mischief my ass, you are an unethical moron." - chsh
    Blog of X

  5. #5
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    I thought Visual C++ would have had plenty of examples on how to use argv and argc.. but anyway.. google throws up plenty indeed.. first hit http://www.google.com/search?hl=en&l...2B&btnG=Search
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  6. #6
    Senior Member codenamevirus's Avatar
    Join Date
    Jun 2005
    Location
    Faridabad, Haryana, India
    Posts
    298
    thnx all of u for the above assistance.

    SirDice, the link really helped, thnx a lot!!
    CodeNameVirus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •