View Full Version : arguments in main

01-17-2005, 08:10 PM
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.

#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.


01-17-2005, 08:34 PM
int main(int argc, char*argv[] )
cout<< argv[1] <<endl; // print to test argument

01-17-2005, 08:39 PM
You the man Kleid-O! :)

01-24-2005, 12:59 AM
You could have always just read the FAQ entry (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046139290&id=1043284392). :rolleyes: