구조체

2021. 3. 30. 13:23프로그래밍 언어/C++

#include <iostream>

#include <cstring>

using namespace std;

int main() {

struct MyStruct

{

string name;

string position;

int height;

int weight; } B;

MyStruct A;

A.name = "Son";

A.position = "Striker";

A.height = 183;

A.weight = 77;

/* MyStruct A = {

"Son",

"Striker",

183,

77 } */

cout << A.name << endl;

cout << A.position << endl;

cout << A.height << endl;

cout << A.weight << endl;

B = {

}

cout << B.height << endl;

MyStruct C[2] = {

{"A", "A", 1, 1},

{"B", "B", 2, 2}

};

cout << C[0].height << endl;

return 0

}

'프로그래밍 언어 > C++' 카테고리의 다른 글

c++ (int/char/short/long 등) size 비교  (0) 2021.04.26
continue  (0) 2021.04.26
break  (0) 2021.04.26
반복문  (0) 2021.04.26
사용자 입력과 string  (0) 2021.03.30