can someone pls help me changing this code to c++
#include <stdio.h>
#include <string>
typedef struct {
char name[32],
surname[64];
unsigned char age;
} Student;
struct StudentItem;
typedef struct StudentItem {
struct StudentItem *next;
Student item;
} StudentItem;
void Student_Input(Student *st) {
printf("Enter Name: "); scanf("%s", &st->name);
printf("Enter Surname: "); scanf("%s", &st->surname);
printf("Enter Age: "); scanf("%d", &st->age);
}
void Student_Output(Student *st) {
printf("| %16s | %24s | %3d |\n", st->name, st->surname, st->age);
}
const char horzLine[] = "-------------------------------------";
void Students_Separator() {
printf("+------------------+--------------------------+-----+\n", horzLine, horzLine, horzLine);
}
void Students_Output(StudentItem *list) {
Students_Separator();
printf("| %16s | %24s | %3s |\n", "Name", "Surname", "Age");
Students_Separator();
StudentItem *item = list;
while (item) {
if (item->item.surname[0]) { // checks whether string `surname` is not empty
Student_Output(&item->item);
item = item->next;
}
}
Students_Separator();
}
StudentItem *Student_New(StudentItem *root) {
StudentItem *item = (StudentItem *) malloc( sizeof(StudentItem) ); // Create the item
if (root)
Last edited on