Fix the bugs regarding extra characters appearing with big number functions
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e189446fe0
commit
c6970bc35d
24
src/main.c
24
src/main.c
@ -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…
x
Reference in New Issue
Block a user