+ 1
Did anyone know how to print and scan a character array in structure in visual studio 2019
3 odpowiedzi
- 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;
}