0
I have the following code to run on the terminal. It checks if the first argument is a '+' and then sums up the following numbers.
int main(int argc, char *argv[])
{
int i, soma;
char oper;
oper = *argv[1];
soma = 0;
if(oper == '+'){
for(i = 2; i <= argc; i++){
soma = soma + atoi(argv[i]);
}
printf("Soma: %d", soma);
}
The question is why
oper = *argv[1]
needs the pointer while
atoi(argv[i])
don’t need
But then the atoi function makes it unnecessary to use pointer in argv[i]?
– Dhonrian