Message from C, C++ discussions

November 2019

— Your question seems unclear to me

— 

So i have a main class and a subclass , in each class i have 2 sifferent pointers , i create a destructor for main class , should i create a destructor for subclass ?

— Where i delete the pointer from derived?

— Guys plz help me. I don't understand why my program crashes

— #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 50
int main()
{
struct personality
{
char surname[SIZE];
char name[SIZE];
int day;
int month;
int year;
int marks[5];
double average;

struct personality *next;
};

struct personality *PZ11;

FILE* fp = fopen("list.txt", "r");
int countStuds;
int symbol; int i = 0;
do {
fscanf(fp, "%s %s", &PZ11->surname, &PZ11->name);
fscanf(fp, "%d %d %d", &PZ11->day, &PZ11->month, &PZ11->year);
for (int j = 0; j < 5; j++)
fscanf(fp, "%i", &PZ11->marks[j]);
i++;
} while (!feof(fp));
fclose(fp);
countStuds = i;


for (int i = 0; i < countStuds; i++)
{
printf("|");
printf("%12s %10s \n", PZ11->surname, PZ11->name);
++i;
}

Message permanent page

— I want to read data from the file to struct using pointer

— Do you know where the program crashes? Put some debug print statements and see where the crash happens or just use gdb

Message permanent page

— I don't know where the problem is because the console doesn't open to me

— Lol

— Lol

— 1. Read the rules.
2. Use visual studio.

— Where do you assign PZ11? Dereferencing results in UB