@Ben_r007

Scanf. Как отключить Security Development Lifecycle в VS 2019?

Здравствуйте.
Пишу программу на C в VS 2019. Создал C++ проект, в настройках проекта выбрал C код, создал файл main.c.
Ругается на Scanf. Показал знакомому, он сказал, что нужно отключить Security Lifecycle. Но у меня нет этого пункта при создании проекта.
Как можно отключить?
Заранее благодарен!

Код:
#include <stdio.h>
#include <string.h>
#include <windows.h>
#define MAX 10
#define KOL 15

struct Student
{
    char Name[KOL];
    int Age;
    float AverageRaiting;
    struct Student* nextStudent;
};

void InitStudentList(struct Student** student)
{
    *student = (struct Student*)
        malloc(sizeof(struct Student));
    printf("Введіть ім’я 1-го студента: ");
    scanf("%s", (*student)->Name);
    printf("Введіть вік 1-го студента: ");
    scanf("%d", &(*student)->Age);
    printf("Введіть середній рейтинг 1-го студента: ");
    scanf("%f", &(*student)->AverageRaiting);
    printf("\n");
    (*student)->nextStudent = NULL;
    struct Student* endStudent = *student;
    for (int i = 2; i <= MAX; i++)
    {
        endStudent->nextStudent =
            (struct Student*) malloc(sizeof(struct Student));
        endStudent = endStudent->nextStudent;
        printf("Введіть ім’я %d-го студента: ", i);
        scanf("%s", endStudent->Name);
        printf("Введіть вік %d-го студента: ", i);
        scanf("%d", &endStudent->Age);
        printf("Введіть середній рейтинг %d-го студента: ", i);
        scanf("%f", &endStudent->AverageRaiting);
        printf("\n");
        endStudent->nextStudent = NULL;
    }
}
void PrintList(struct Student* student)
{
    struct Student* printStudent = student;
    printf("==========================\n");
    printf("Ім’я         Вік  Рейтинг \n");
    printf("==========================\n");
    while (printStudent)
    {
        printf("%-15s", printStudent->Name);
        printf("%4d", printStudent->Age);
        printf("%8.2f", printStudent->AverageRaiting);
        printf("\n");
        printStudent = printStudent->nextStudent;
    }
    printf("==========================\n");
}

void FreeList(struct Student** student)
{
    if (*student == NULL)
        return;
    struct Student* tmp = *student;
    struct Student* curr_stud;
    while (tmp)
    {
        curr_stud = tmp;
        tmp = tmp->nextStudent;
        free(curr_stud);
    }
    *student = NULL;
}

int main(void)
{
    struct Student* BaseStudent = NULL;
    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);
    InitStudentList(&BaseStudent);
    PrintList(BaseStudent);
    FreeList(&BaseStudent);
    return 0;
}
  • Вопрос задан
  • 163 просмотра
Пригласить эксперта
Ответы на вопрос 1
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы