Bignumber Subtraction


 
void Subtraction(char *f, char *s, char *ans){
	int lenf,lens,a,carry,ind,b;
	lenf = strlen(f)-1; lens = strlen(s)-1;
	carry = ind = 0;
	while(lens >=0 || lenf >=0){
		b = ((lens >=0)?(s[lens--]-'0'):0) + carry; 
		if(f[lenf] >=(b+'0')){a = f[lenf--]-'0';carry = 0;}
		else{a = f[lenf--]-'0' + 10;carry = 1;}
		ans[ind++] = (a - b) + '0';
	}
	for(ind--;ind >=0;ind--)if(ans[ind]!='0')break;
	ans[++ind] = 0;
	reverse(ans,ans+ind);
}