**Argv - where?

This is a discussion on **Argv - where? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Salem That is only true of DOS .COM files. Almost right (it is true of more than ...

  1. #16
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Quote Originally Posted by Salem
    That is only true of DOS .COM files.
    Almost right (it is true of more than just COM files), but my half-true statement was merely the result of an attempt to illustrate how the OS handles the command line, while your implication that it has a virtually unlimited length is completely unfounded. See the attached program. The code follows. Included is a batch file with a couple of very long command line arguments. Try running it. If what you're saying is correct, every character in the command line will be printed.
    Code:
    #include <iostream>
    using namespace std;
    
    int main(int argc, char **argv) {
      cout << "Here are our command line arguments:" << endl;
      for (int i = 0; i < argc; ++i)
        cout << argv[i] << endl;
      cout << endl;  
    
      return 0;
    }
    Quote Originally Posted by CornedBee
    And it might yet again be different in ELF executables and a.out executables.
    By
    Quote Originally Posted by LuckY
    On an x86 machine...
    I meant on an x86 Windows machine. Obviously different operating systems don't all manage executables in an equivalent manner.
    Attached Files Attached Files
    Last edited by LuckY; 12-22-2004 at 02:24 PM. Reason: Typo

  2. #17
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,657
    >> Try running it

    hmm, yeah - running Windows 2000 it stopped at almost exactly 2K (2037 total).



    ITSA
    Socket Library!

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

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