본문 바로가기

카테고리 없음

[C++] 배열을 포함하는 구조체 연습

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;
 
struct StudentInfo
{
   char name[20];
   int stdNumber;
   float grade[2];
};
 
int main()
{
 
   studentInfo si = {"Kim Chol-Su"200121233, {3.2f,3.5f} };
 
   cout << si.name << "\n";
   cout << si.stdNumber<< "\n";
   cout << si.grade[0<< "," << si.grade[1<< "\n"
 
   return 0;
}
cs