Menu

passing arguments to C++ programs

2002-10-08
2012-09-26
  • Nobody/Anonymous

    Hi,
      I am new to Dev C++ environment and I am trying to run some programs in a project created in the latest Dev C++ 5.0 Beta version of the IDE. I am having trouble trying to pass command-line arguments as in standard C program via (argc, argv) . Can't seem to figure out where to write them !! Some enlightenment will be greatly appreciated.

    Thanks

    Bijit

     
    • Nobody/Anonymous

      Remember  C++  here...

      Ok, as a function:
                      int myfunc ( in here the arguments are declared. )
                             {
                                ...body of function....
                              }

      Note: ------------------------------------------------------------------------
                    int main(int argc, char *argv[])
                      {
                       ...body of function....
                      }              
      Here the [ type + argument-name ] then a comma.
      from above   int argc,  ... the same and so on as many arguments as you need.

      These arguments now declared, recevie information passed to the function.
      Within the body of the function these arguments can be used as local variables: Assignments can be made to them, and can be used in statements.

      Hope this will help...

      j@ck_

       
    • Nobody/Anonymous

      Assignments can be made to them, and can be used in statements within that  function !...

      sorry about that..
      j@ck_

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.