hello, i wanna ask if somebody can help me with this problem.
First code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
if(argc>1)
{
int i=1, zmnozek=1;
zmnozek=atoi(argv[1]);
for(i=1; i<argc; i++)
{
zmnozek*=atoi(argv[i]);
};
printf("Rezultat: %d\n",zmnozek);
}else
{
printf("Nepravilen vnos!\n");
};
return 0;
}
And there is the problem: When i use it to multiply positive numbers it comes out ok, but when i want to multiply for example 8 and -2 it comes out -128. Can anyone help?
Thanks in advance