-
Notifications
You must be signed in to change notification settings - Fork 0
sadness #76
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?
sadness #76
Conversation
yurii-litvinov
left a comment
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.
Вообще, не считая весьма досадной путаницы с позициями, годно и аккуратно. Но не работает
| free(element); | ||
|
|
||
| } |
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.
| free(element); | |
| } | |
| free(element); | |
| } |
| #pragma once | ||
| #include "../../List/List/List.h" | ||
|
|
||
| int readFile(const char* filename, List* list); |
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.
Надо бы комментарии ещё
| #include <string.h> | ||
| #include <stdlib.h> | ||
|
|
||
| List* removeRepeatElement(List* list, Error* 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.
"Repeating" лучше
| List* newList = createList(error); | ||
| Position* position = first(list, error); | ||
| Position* newPosition = first(list, error); | ||
| while(!isLastElement(position)) |
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.
| while(!isLastElement(position)) | |
| while (!isLastElement(position)) |
| Position* newPosition = first(list, error); | ||
| while(!isLastElement(position)) | ||
| { | ||
| newPosition = position; |
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.
Не-а, это не "создать копию позиции position", это "давайте эту же область памяти, на которую указывает position, называть ещё newPosition". Поэтому когда Вы делаете newPosition = next(newPosition);, продвигается и position тоже. Ваш код к этому морально не готов и падает после первой итерации внешнего цикла. Надо было сделать функцию копирования позиции, и всё бы заработало. В отладчике же видно, что происходит :)
No description provided.