Thread: argc argv any real point

  1. #1
    Unregistered
    Guest

    argc argv any real point

    ok guys I can see the importance of argv and argc in dos but seen as how most people will click on an icon to run a prog and when the prog is running input goes straight to that prog avoiding the command line is there are real use for these functions today as I'm not sure how long windows will ship with dos or even if it still does.

    thanks for the guidence.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Full blown Windows Apps still take arguments.....

    When you double click a .txt file, the registry looks up ".txt" which points to a key like "txtfile" which then runs the following command

    "notepad.exe %1"

    The "%1" is a string representing the name of the file you clicked.

  3. #3
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Some applications let you take an application by pointing at it and holding the mouse button down, than dragging it on top of another applications icon. This becomes a command line argument, for example windows media player will let you do this.

  4. #4
    Unregistered
    Guest
    fordy I know this was yesterday but still got problems with the system() function.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    >>fordy I know this was yesterday but still got problems with the system() function.

    Oh....still aint working??

    Post your code, tell me what your OS is and exactly how you are excecuting it....

  6. #6
    Unregistered
    Guest
    #include<stdlib.h>
    #include<conio.h>

    int main()
    {
    system("dir");
    system("dir c:\\");
    system("dir c:\\*.txt);

    /* non of these work */

    getch();
    return 0;
    }
    not running from the command prompt but straight from the compiler.


    borland compiler dos prog running on win 95.

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Right, do this.

    Code:
    command
    Type that into notepad and save as dos.bat. Copy it into the same folder as your .exe file. Double click and a dos console will appear. Type in the name of your program and press enter....you should now see the results.

    Dont fear the command prompt....... I never use getch() to keep the console open...I much prefer the command prompt and it avoids bloopers like this

  8. #8
    Unregistered
    Guest
    ok done that but comes back with bad command of filename

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Make sure that the excecutable is in the same directory as the bat file you are running in.....


    If your executable is myprog.exe, type myprog onto the commandline

  10. #10
    Unregistered
    Guest
    ok. the .exe is in the same direcrory as the .bat file
    still comes back with bad command or filename.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Header files and classes
    By disruptivetech in forum C++ Programming
    Replies: 5
    Last Post: 04-21-2008, 09:02 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Converting a argc / argv construct into a va_list
    By chambece in forum C Programming
    Replies: 6
    Last Post: 07-03-2005, 04:47 PM
  4. argc and argv
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 05-03-2002, 05:21 PM
  5. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 04:38 PM