CSC 202 Session 3
CSC 202 Session 3
DATA STRUCTURES IN C ++
. . .
csc_student name, csc_student level, csc_student age
etc.
Remember that the first component of an expression
involving the dot operator is the name of the specific
structure variable (csc_student), not the name of the
structure definition (student).
.
EXAMPLE
#include <iostream>
using namespace std;
struct
{
char name[50], address[100];
int age;
float salary;
} personnel;
int main()
{
// Staff personnel;
return 0;
}
ARRAY OF STRUCTURES
struct student
{
char name[50];
int age;
int level;
int No_of_Courses;
char Matric_no[15];
} csc_student[100];
OR inside main () as
student csc_student[100];
ACCESSING MEMBERS OF THE ARRAY
#include <iostream>
cout << "\nYou have entered these
#include <string>
movies:\n";
using namespace std;
int main ()
cout<<"\nProducer:"<<films[n].producer
{
<<endl;
int n;
for (n=0; n<3; n++)
{ cout << "Enter title: "; }}
getline (cin, films[n].title);
cout << "\n Enter Producer: ";
getline (cin, films[n].producer);
}
Programming Task