Я запускаю сценарий оценки для проверки моей программы (https://github.com/houi-lin/cmps101-pt.u19.grading/tree/master/pa1) Но я получаю массу таких же ошибок, я не знаю, как подойти.
Я ужепопытался освободить переменные, которые я определил, но это не помогло.
fptr=fopen(argv[1],"r");
if(fptr==NULL)
{
printf(" File does not exist or can not be opened.");
}
else
{
while((ch = getc(fptr)) != EOF)
{
if(ch == '\n')
wrd++;
}
fclose(fptr);
fptr=fopen(argv[1],"r");
char *str[wrd];
int i=0;
while((ch = fgetc(fptr)) != EOF)
{
if(ch == '\n')
{
printf("\n is in the %d",i);
i++;
}
else
{
cToStr[0] = ch;
printf("%c",ch);
strcat(b[i], cToStr);
}
} printf("%d",wrd);
display(wrd,b, argv[2]);
fclose(fptr);
}
return 0;
}
==10790==
==10790==
==10790== 10000 errors in context 24 of 34:
==10790== Invalid write of size 1
==10790== at 0x400B3D: main (Lex.c:61)
==10790== Address 0x1ffec2ea80 is on thread 1's stack
==10790== in frame #0, created by main (Lex.c:53)
==10790==
==10790== ERROR SUMMARY: 13544 errors from 34 contexts (suppressed: 0 from 0)