Thread: **Argv - where?

  1. #16
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    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.
    #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.
    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.
    Last edited by LuckY; 12-22-2004 at 03:24 PM. Reason: Typo

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

    hmm, yeah - running Windows 2000 it stopped at almost exactly 2K (2037 total).
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

Popular pages Recent additions subscribe to a feed