+ 1

Did anyone know how to print and scan a character array in structure in visual studio 2019

9th Oct 2021, 6:41 AM
Sumit Acharya
Sumit Acharya - avatar
1 ответ
- 2
you can try this... struct student{ char name[10]; int en_num; }; int main(){ int n=2,i; struct student s[i]; // For scanning values for(i=0;i<n;i++){ cout << "Enter name: "; cin >> s[i].name; cout << "Enter roll number: "; cin >> s[i].en_num; } //For printing values for(i=0;i<n;i++){ cout<<"\nStudent"<<i+1<<"details:\n"; cout<<"\nName: "<<s[i].name; cout<<"\nRoll number: "<<s[i].en_num; } return 0; }
9th Oct 2021, 7:36 AM
Indira
Indira - avatar