ok, heres my main
Code:
class BigNum{
public:
char input[1000];
BigNum();
BigNum(char* );
char* convert(char *);
int counter;
};
BigNum output; char num1[1000];
char num2[1000];
char *numm1;
cout << "Enter first input"<< endl;
cin >> num1;
cout << endl;
BigNum input1(num1);
numm1 = input1.convert(num1);
strcpy(num1, numm1);
cout << "Enter second input"<< endl;
cin >> num2;
BigNum input2(num2);
numm1 = input2.convert(num2);
strcpy(num2, numm1);
return 0;
}
BigNum::BigNum(char* input){
strcpy(this->input, input);
}
BigNum::BigNum(){
strcpy(input, "\0");
counter = 0;
}
char* BigNum::convert(char* input){
int temp, temp2, temp3;
for(temp = 0;input[temp] != '\0';temp++);
temp = 1000 - temp;
for(temp2 = 0;input[temp2] != '\0';temp2++, temp++){
input[temp] = input[temp2];
}
temp2 = 1000 - temp2;
for(temp3 = 0;temp3 < temp2;temp3++){
input[temp3] = '0';
}
input[1000] = '\0';
return input;
}
the convert function simply moves the numbers in the string to the end of the string so it looks like from "123\0" into "00000123\0" where \0 is the end of string.
my problem is during my second cin for the second input. when i display my first input right after the cin of the second input, the second input gets connected/combined with my first input. its like: if my first input is 123. my first input, after going through the convert function, would look like this 0000123. then i would put my second input, which would be 321. if i display my first input right after the cin of the second one, it would look like this 0000123321. why?