C++ Data Structures - Struct:
In this tutorial, I give you a very basic example and simple explanations to how structs work. This tutorial is to serve as a base for future tutorials dealing with structs and other data structures.
In future tutorials, I expect to show you how to use structs with Arrays as well as functions. If you have any questions about the program or functions in general, feel free to ask.
I hope you enjoy the video and if you have any requests feel free to let me know.
#include <iostream>
#include <string>
using namespace std;
struct student
{
string name;
int grade;
};
int main()
{
student pupil1;
student pupil2;
cout << "Please enter student's name: ";
cin >> pupil1.name;
cout << "Please enter student's grade: " ;
cin >> pupil1.grade;
cout << "Please enter student's name: ";
cin >> pupil2.name;
cout << "Please enter student's grade: " ;
cin >> pupil2.grade;
cout << "Name" << " " << "Grade" << endl;
cout << pupil1.name << " " << pupil1.grade << endl;
cout << pupil2.name << " " << pupil2.grade << endl;
system("pause");
}