/* This example displays some information about a student. */ #include <string.h> #include <iostream> using namespace std; struct STUDENT { char name[20]; int id; int mark[3]; }; int main () { STUDENT stu; char student_name[20]; int i; cout << "Your name, please: "; cin.getline(student_name, 20, '\n'); // command to input a string strcpy(stu.name, student_name); stu.id = 1999; cout << "Enter your marks for three tests." << endl; for (i=0; i < 3; i++) { cout << "Test " << i+1 << ": "; cin >> stu.mark[i]; } cout << endl; cout << "Hello, " << stu.name << endl; cout << "Your Student ID is " << stu.id << endl; cout << "Your marks are: " << endl; for (i=0; i < 3; i++) { cout << "Test " << i+1 << ": " << stu.mark[i] << " " << endl; } }