Thread: argv = LPSTR string, argc = int cmdShow?

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    argv = LPSTR string, argc = int cmdShow?

    Hey guys. I was wondering if anyone new the equivalent to C's **argv and argc? I had a hunch it was the last two parameters of the standard WinMain arguments, the LPSTR and int variable.

    But even if so, I cannot manipulate them as such. For instance, with C's **argv variable, I can do:

    puts(argv[0]);

    But

    TextOut(hdc, x, y, myLpstr[0], len);

    crashes my system!

    So either I got the wrong variables, or else I just am wrong that a LPSTR is just a typedef for a char **...

    Any idea?

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    2
    You can use the function GetCommandLine() to retrieve the entire string in that variable.

    I think it is just a single char * and not a **.

    -Mezz

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Cool, thanks. So I'm assumming all of the args have simply been pasted onto a single string?

    Cheers...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    2
    Yes I'm guessing so, I've never actually bothered much with the cmd line yet in Win32 apps.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Hmmm, actually, GetCommandLine() returned a NULL! And that was even after I dropped like ten files into the program to open it!
    Nothing worked. Is it simply not one of the parameters of WinMain? Surely the last two, the LPSTR and int? Then again that int,( usually "cmdShow" or "nFunsterstil", I called mine simply argc!!) returned wacky results too, sometimes printing out 0, 5, 1, etc, not even the number it should've counted...
    ...sigh...I hate Windows!!!

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Got it! Thanks...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            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

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  3. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  4. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM