Skip to content

Сделал всё - #3

Open
Palezehvat wants to merge 1 commit into
mainfrom
KRNumber3
Open

Palezehvat wants to merge 1 commit into
mainfrom
KRNumber3

Conversation

@Palezehvat

Copy link
Copy Markdown
Owner

No description provided.

#include <string.h>
#include <stdbool.h>

bool scanFile(char fileName[], char arrayForTest[]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool scanFile(char fileName[], char arrayForTest[]) {
bool scanFile(const char fileName[], const char arrayForTest[]) {

Мы их вроде ниже не меняем

}
char data[100] = { '\0' };
int pointerTest = 0;
while (fscanf(file, "%s", data) == 1){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
while (fscanf(file, "%s", data) == 1){
while (fscanf(file, "%s", data) == 1) {

if (fileName != NULL && strcmp(fileName, "test.txt") != 0) {
printf("%c", data[0]);
} else {
if (arrayForTest[pointerTest] != data[0]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вообще, в боевом коде не должно быть ничего про тесты. Тест должен тестировать наблюдаемое извне поведение настоящего кода, а не какой-то кастомный код, написанный специально под тест в реальной системе.

printf("%c", data[0]);
} else {
if (arrayForTest[pointerTest] != data[0]) {
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Файл останется незакрытым

Comment on lines +45 to +47
char fileName[9] = "test.txt";
char arrayTest[4] = "abc";
return scanFile(fileName, arrayTest);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот если бы scanFile принимала const-ы, то эти переменные были бы не нужны

return true;
}

bool test(){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool test(){
bool test() {

}
else {
printf("Mistake...\n");
return 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0;
return 1;

}

int main(void) {
setlocale(LC_ALL, "RUS");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что-то тут отступов многовато

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants