but it doesn't work properly on bcc.what am I gonna do??I worked for 5 days for a code but it means nothing .....could you check it and tell me what is wrong with it??
THE code:multiple two numbers 1-250 digits but it's forbidden to use "float" or "double" in the code...
Code:
#include <stdio.h>
#include <string.h>
char multiplicand[251];
char multiplier[251];
char input[501];
char x[255];
char y[255];
char digit[510];
char carry[510];
int main(void)
{
int m, n;
char *p;
int i, j;
int temp;
fgets(input, 501, stdin);
p = strchr(input, '*');
*p = ' ';
sscanf(input, "%[0123456789] %[0123456789]", multiplicand, multiplier);
m = strlen(multiplicand);
n = strlen(multiplier);
memset(x, '0', 255);
memset(y, '0', 255);
memmove(x+(255-m-1), multiplicand, (m+1));
memmove(y+(255-n-1), multiplier, (n+1));
memset(digit, '0', 510);
memset(carry, '0', 510);
for(j = 253; j >= 0; j--) {
for(i = 253; i >= 0; i--){
temp = (x[i] - '0') * (y[j] - '0') + (carry[i+j+1]-'0');
digit[i+j+1] += (temp % 10);
if(digit[i+j+1]>'9'){
digit[i+j] += (digit[i+j+1]-'0')/10;
digit[i+j+1] = (digit[i+j+1]-'0')%10 + '0';
}
carry[i+j] += (temp / 10);
carry[i+j+1] = '0';
}
}
puts(digit);
return 0;
}
please help...I will get zero..