Fix up the add() function to support variable-length numbers

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago committed by GitHub
parent 1a6e740f28
commit 8e36ea0ab3
  1. BIN
      current
  2. 2
      src/main.c
  3. 2
      src/utils.c

Binary file not shown.

@ -8,6 +8,6 @@
*/
int main(int argc,char**argv) {
printf("%s",add((struct String){7,"1845920"},(struct String){4,"1829"}).str);
return 0;
}

@ -23,7 +23,7 @@ struct String add(struct String numb1, struct String numb2){
}
}
} else {
for (int offset=0;offset<numb1.length;offset++) {
for (int offset=0;offset<numb2.length;offset++) {
str = realloc(str,++digitCount);
//printf("Digit count is now %d\n",digitCount);
if (numb1.length>offset) {

Loading…
Cancel
Save