Thread: arguments in main

  1. #1
    Registered User cdonlan's Avatar
    Join Date
    Sep 2004
    Posts
    49

    arguments in main

    So I have decided to put down the ms c++ and go linux for my first program this semester. It went well, got the hang of emacs,g++, and gtb. I was thinking "Hey , I can deal with this stuff. No need to usw MS product for my stumble through the C++ programming". There is just one problem here. How do set my main arguments when I run my program. Here is my code.

    Code:
    #include  <iostream>
    #include <string.h>
    
    using namespace std;
    
    void convert(int input,int base, int counter);
    void add(int);
    void report();
    
    
    
    int main(int argv, char*argv[] )
    {
      cout<< argv<<endl; // print to test argument
      
    ...
    ....
    .....
    when I run a.open 40. It prints 2.
    Any ideas would be great.

    Thanks

  2. #2
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Code:
    int main(int argc, char*argv[] )
    {
      cout<< argv[1] <<endl; // print to test argument

  3. #3
    Registered User cdonlan's Avatar
    Join Date
    Sep 2004
    Posts
    49
    You the man Kleid-O!

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could have always just read the FAQ entry.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Too many arguments to function int main?
    By plain in forum C++ Programming
    Replies: 13
    Last Post: 08-29-2006, 06:01 PM
  2. Actient main
    By swgh in forum C Programming
    Replies: 2
    Last Post: 03-21-2006, 01:33 PM
  3. C99 and int main()
    By cwr in forum C Programming
    Replies: 8
    Last Post: 09-19-2005, 06:54 AM
  4. Passing arguments to main?
    By xddxogm3 in forum C++ Programming
    Replies: 4
    Last Post: 10-16-2003, 03:59 AM
  5. arguments passed to main?!?
    By threahdead in forum C++ Programming
    Replies: 14
    Last Post: 01-22-2003, 08:43 PM