-
Notifications
You must be signed in to change notification settings - Fork 0
Поиск подстроки #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Поиск подстроки #27
Conversation
| { | ||
| return MEMORY_ERROR; | ||
| } | ||
| char *text = readFile(FILE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проверить на NULL
semester_1/Homework11/src/readFile.c
Outdated
| } | ||
|
|
||
| return str; | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переноса нет
semester_1/Homework11/src/readFile.c
Outdated
| if (str == NULL) | ||
| { | ||
| exit(MEMORY_ERROR); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот такие приколы лучше не делать в функциях, которые могут вызываться в произвольном участке программы, когда мы ещё не сохранили данные и не почистили память в вызывающем коде
| if (file == NULL) | ||
| { | ||
| exit(FILE_ERROR); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут аналогично - просто вернуть NULL
| else | ||
| { | ||
| if (len != 0) | ||
| { | ||
| len = lps[len - 1]; | ||
| } | ||
| else | ||
| { | ||
| lps[i] = 0; | ||
| ++i; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if + else
| static size_t *createLPSArray(char const *const pattern, const size_t pLength) | ||
| { | ||
| size_t len = 0; | ||
| size_t *lps = (size_t *)malloc(pLength * sizeof(size_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проверить на NULL
semester_1/Homework11/src/test.c
Outdated
| if (text == NULL) | ||
| { | ||
| free(pattern); | ||
| fclose(testFile); | ||
| return false; | ||
| } | ||
| fclose(testFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
один раз закрыть файл перед if
| return false; | ||
| } | ||
|
|
||
| FILE *answerFile = fopen(answerFileName, "r"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проверить на NULL
semester_1/Homework11/src/test.c
Outdated
|
|
||
| FILE *answerFile = fopen(answerFileName, "r"); | ||
| size_t answer = 0; | ||
| int scanfCheck = fscanf(answerFile, "%lu", &answer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%l - на случай, если ответ -1
| } | ||
| } | ||
| free(lps); | ||
| return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t - unsigned long -> переделать size_t на long
No description provided.