Jump to content

  • Log In with Google      Sign In   
  • Create Account

C++ Question


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1   Members   

122
Like
Likes
Like

Posted 29 January 2002 - 06:14 PM

I am trying to get numbers from the command line as arguments. Just to try it out I did something like: int main(int argc, char* argv[]) { int a = (int) argv[1]; int b = (int) argv[2]; int c = a + b; //etc... } Only problem is, this didn''t work. Any suggestions how to do this? The usage is something like ''program . Thank You, pigsfl3w

#2   Members   

476
Like
Likes
Like

Posted 29 January 2002 - 06:16 PM

Try this ...
int a = atoi(argv[1]);
int b = atoi(argv[2]);
int c = a + b;


#3   Members   

122
Like
Likes
Like

Posted 29 January 2002 - 06:20 PM

What header file is atoi() in?

#4 Anonymous Poster_Anonymous Poster_*   Guests   

Likes

Posted 29 January 2002 - 06:25 PM

#include <stdio.h>




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.