Accessing command line arguments in C -
please forgive me if noob question, i'm beginner @ c, learning while. tried write program sums 2 numbers (provided params application). code this:
#include <stdlib.h> #include <stdio.h> int main( int argc, char** argv) { int = atoi(argv[0]); int b = atoi(argv[1]); int sum = a+b; printf("%d", sum); return 0; }
but incorrect results - huge numbers small inputs 5 , 10. wrong here?
the first argument program name of program itself. try using following instead.
int = atoi(argv[1]); int b = atoi(argv[2]);
Comments
Post a Comment