Fix the bugs regarding extra characters appearing with big number functions

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago committed by GitHub
parent e189446fe0
commit c6970bc35d
  1. BIN
      current
  2. 24
      src/main.c

Binary file not shown.

@ -14,28 +14,34 @@
int main(int argc,char**argv) {
FILE*file = fopen("p022_names.txt","r");
printf("%s\n",add(BigNumber(38195431534281091050778),BigNumber(381918429378)).str);
/*int pointer=0;
int pointer=0;
int nameCount=0;
char**names = malloc(sizeof(char*));
while (!feof(file)) {
if (fgetc(file)=='"') {
while (fgetc(file)!='"') {
}
nameCount++;
}
}
fseek(file,0,0);
const char*names[nameCount];
while (!feof(file)) {
int currentCount=0;
if (fgetc(file)=='"') {
//Start reading the name.
char*newName=malloc(1);
char c=' ';
int length=0;
int length=1;
while ((c=fgetc(file))!='"') {
newName=realloc(newName,++length);
newName[length-2]=c;
newName[length-1]='\0';
}
nameCount++;
names=realloc(names,sizeof(char*)*nameCount);
names[nameCount-1]=newName;
names[currentCount++]=newName;
}
}
for (int i=0;i<nameCount;i++) {
printf("%s\n",names[i]);
}*/
printf("%s\n",(char*)((*names)[i]));
}
return 0;
}
Loading…
Cancel
Save