how to read an argument from the terminal in visual c++ studio

This is a discussion on how to read an argument from the terminal in visual c++ studio within the Windows Programming forums, part of the Platform Specific Boards category; hi everybody! I have made some searching in google about this problem but could not find an answer My problem ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    19

    how to read an argument from the terminal in visual c++ studio

    hi everybody!
    I have made some searching in google about this problem but could not find an answer
    My problem is following:
    I want to read the name of a file when i run a program in visual c++ express studio
    fp = fopen(argv[1], "r"); // the name of the program, read from terminal
    in linux i know how to do but in visual studio it seems more complex
    The only thing i can see in the visual studio is start debuging and start without debuging.
    Is there any way to read a value from terminal (like a filename for example) when you run a program in visual c++ express studio?
    Last edited by kobra_swe; 11-20-2007 at 03:03 PM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Do you mean a command line argument? Yes, you can set that in visual studio somewhere in the project options.

    I'll post back in a few minutes when I have checked where it is.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Right, if you right-click on your project [in the project pane], and select "Properties" in the pop-up menu. In the dialog that comes up, select debugging, and there's a "command arguments" which will be what's passed to your application in the argv[] array.

    If that's not what you actually wanted, then please explain what you wanted.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Jul 2006
    Posts
    19

    a little problem

    i typed the path to the file i wanted to read in Comman d arguments
    C:\prog\minfil.txt
    but i get following error
    c:\Users\anton\Documents\Visual Studio 2005\Projects\ass1\assig\debug\assig1.exe
    : cannot open file "c:\prog\minfil.txt" for reading: No such file or directory
    Press any .....
    I have made a check and the path to the file is correct, i can open the file with
    c:\prog\minfil.txt
    Does somebody know's what it is and how do i solve it?

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Are you sure about both the location and name of the file? It should work - I've used it before.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to compile projects ?
    By manzoor in forum C++ Programming
    Replies: 31
    Last Post: 10-15-2008, 12:52 PM
  2. multiple errors generated by socket headers
    By nocturna_gr in forum Windows Programming
    Replies: 5
    Last Post: 12-16-2007, 06:33 PM
  3. Problem Compiling Program
    By wco5002 in forum C++ Programming
    Replies: 13
    Last Post: 11-06-2007, 12:56 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM

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