0
Each student is identified by 4 digit Id. The number of student is unknown. However the last id number is 0000. Which is the file. How do i intialize my array to what size?? Or do i have to wirte any loop.
2 Respuestas
+ 2
int nStudents;
cout << "Enter the number of students: ";
cin >> nStudents;
int *pStudents = new int[nStudents];
then you can use this pointer like you would a normal array.
for (int i = 0; i < nStudents; i++) {
cout << "Enter student id: ";
cin >> pStudent[i];
}
0
int arr[];
//you can use empty brackets if you dont'n know the number of students...