Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. parameters

parameters

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
22 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Perestroyka

    thanks Its parameter the right name for this?

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #13

    Technically there is a difference between parameters and arguments. Most folks use them interchangeably, and thus can lead to confusion.


    "One must learn from the bite of the fire to leave it alone." - Native American Proverb

    P 1 Reply Last reply
    0
    • D David Crow

      Technically there is a difference between parameters and arguments. Most folks use them interchangeably, and thus can lead to confusion.


      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

      P Offline
      P Offline
      Perestroyka
      wrote on last edited by
      #14

      How do you call this what I want? arguments or parameters?

      D 1 Reply Last reply
      0
      • P Perestroyka

        How do you call this what I want? arguments or parameters?

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #15

        void foo( int x ) // the parameter is x
        {
        }

        void main( int argc, char *argv ) // the parameters are argc and argv
        {
        foo(123); // the argument is 123
        }

        if this program were started at a command prompt like myprog.exe -excavator, the argument would be -excavator.


        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

        1 Reply Last reply
        0
        • P Perestroyka

          FOR EXAMPLE: This testfile.exe is normaly running in fullscreen. But it has parameters wich can be used to run it in a small windows size. The problem is: How do you get those parameters?

          R Offline
          R Offline
          rwilmink
          wrote on last edited by
          #16

          CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); cmdInfo.m_strFileName now contains the commandline.

          D 1 Reply Last reply
          0
          • R rwilmink

            CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); cmdInfo.m_strFileName now contains the commandline.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #17

            rwilmink wrote: cmdInfo.m_strFileName now contains the commandline. Only in specific instances (i.e., if the shell command is New or DDE). If you specified an argument that was not recognized by CCommandLineInfo, it would not show up in any of the member variables.


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            P 1 Reply Last reply
            0
            • M Maximilien

              you need to do this from the source code, not from the command line ( or if that's the case, juste copy paste the arguments ) from the a simple C or C++ source code : int main ( int argc, char* argv[] ) { /// argc is the number of arguments /// argv is the string containing the arguments. /// argv[0] is the program /// from argv[1] are the arguments /// you need to parse them manually. } from a MFC application : BOOL YouApp::InitInstance() { /// use the CCommandLineInfo class. CCommandLineInfo cmdLineInfo; }


              Maximilien Lincourt Your Head A Splode - Strong Bad

              R Offline
              R Offline
              Rick York
              wrote on last edited by
              #18

              You can access __argc and __argv in Win32 applications also. This is what MFC does in CCommandLineInfo and why I rarely use it myself. You end up peeling the args back apart so I see little point to it. BTW - if you don't believe me then check the MFC source code. :)

              1 Reply Last reply
              0
              • D Dy

                With MFC? Look at CWinApp::m_lpCmdLine. Without MFC? Look at lpCmdLine in WinMain


                -Dy

                R Offline
                R Offline
                Rick York
                wrote on last edited by
                #19

                You can also access __argc and __argv in windoze applications both with and without MFC. Just include stdlib.h. I recommend checking the source code for CCommandLineInfo for more enlightenment on this issue. :)

                1 Reply Last reply
                0
                • D David Crow

                  rwilmink wrote: cmdInfo.m_strFileName now contains the commandline. Only in specific instances (i.e., if the shell command is New or DDE). If you specified an argument that was not recognized by CCommandLineInfo, it would not show up in any of the member variables.


                  "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                  P Offline
                  P Offline
                  Perestroyka
                  wrote on last edited by
                  #20

                  Thank you very much for your suggestions. Could you tell me your theory how you think it should be done?

                  D 1 Reply Last reply
                  0
                  • P Perestroyka

                    Thank you very much for your suggestions. Could you tell me your theory how you think it should be done?

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #21

                    As was mentioned here, -Dy has already answered your question for both MFC and non-MFC. What else are you looking for?


                    "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                    P 1 Reply Last reply
                    0
                    • D David Crow

                      As was mentioned here, -Dy has already answered your question for both MFC and non-MFC. What else are you looking for?


                      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                      P Offline
                      P Offline
                      Perestroyka
                      wrote on last edited by
                      #22

                      oh ok thats it thank you

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups