Please forgive me if this is a question about noob, but I'm new to C, studying only for a while. I tried to write a program that sums up two numbers (provided as parameters for the application). The code looks like this:
#include <stdlib.h>
#include <stdio.h>
int main( int argc, char** argv)
{
int a = atoi(argv[0]);
int b = atoi(argv[1]);
int sum = a+b;
printf("%d", sum);
return 0;
}
But I get the wrong results - huge numbers even for small inputs like 5 and 10. What is wrong here?
source
share