J
johnny
Can anyone tell me what is wrong with the following code fragment?
char a = x[index];
char b = y[index];
int result = strtol(&a, NULL, 10) + strtol(&b, NULL, 10);
I got the same result using result=atoi(&a)+atoi(&b);
cout << a << '\t' << b << endl; shows the values of a and b to be correct.
cout << atoi(&a) (or strtol(&a, NULL, 10)) is correct but atoi(&b) and
strtol(&b, NULL, 10) are incorrect.
This project is suppose to take integers of "unlimited" size and add them.
Mandrake Linux 10, gcc-c++-3.3.2-6mdk, kernel 2.6.3-15mdk
char a = x[index];
char b = y[index];
int result = strtol(&a, NULL, 10) + strtol(&b, NULL, 10);
I got the same result using result=atoi(&a)+atoi(&b);
cout << a << '\t' << b << endl; shows the values of a and b to be correct.
cout << atoi(&a) (or strtol(&a, NULL, 10)) is correct but atoi(&b) and
strtol(&b, NULL, 10) are incorrect.
This project is suppose to take integers of "unlimited" size and add them.
Mandrake Linux 10, gcc-c++-3.3.2-6mdk, kernel 2.6.3-15mdk