프로그래밍(25)
-
[C++] 18. 구조체변수의 포인터 vs 정수형변수의 포인터
구조체를 이전에 배웠다. 구조체는 직접 만들어서 쓰는 데이터 타입이라고 한다. 마치 도장을 찍는 것처럼 구조체와 배열을 써서 실습을 해봤다 문제는 지금부터다 '함수라는 기능을 써서 배열의 반복문을 좀 더 효율적으로 써볼 수 있지 않을까'라는 접근으로 함수를 호출해보기로 한다 그리고 구조체 포인터변수와 정수형변수의 포인터변수를 비교해볼것이다. 1. #include #include using namespace std; // 함수의 기능을 써서 구조체를 만들고 싶다 struct Student { string name; int age; int id; }; void PrintInfo(Student target) { cout
2022.05.31 -
[C++] 구조체를 써서 축구팀을 만들어 보자
#include #include using namespace std; struct SoccerPlayer { string name; int age; string position; string club; }; void main() { SoccerPlayer soccerPlayerA; soccerPlayerA.name = "오사쯔"; soccerPlayerA.age = 28; soccerPlayerA.position = "미드필더" ; soccerPlayerA.club = "경일마드리드"; SoccerPlayer soccerPlayerB; soccerPlayerB.name = "손흥민"; soccerPlayerB.age = 30; soccerPlayerB.position = "윙어"; soccerPlayer..
2022.05.31 -
[C++] 17. 구조체
#include #include using namespace std; // 구조체 : 직접 만들어서 쓰는 데이터타입, 일종의 '도장'찍는 것과 같다. // struct 데이터타입 // { //속성 : 데이터타입과 관련된 요소들 // }; struct Student { string name; int age; int id; }; void main() { int num; Student studentA = { "오사쯔", 28, 130356 }; // 멤버변수를 초기화 하는 또다른 방법 Student studentB;//studentA와 studentB는 멤버들의 값이 동일해도 서로 다른 객체이다. studentB.name = "쏘니"; studentB.age = 25; studentB.id = 120214; ..
2022.05.31 -
[C++] 16. 2차원배열
#include using namespace std; void main() { int scoreA = 10; int scoreB = 20; int scoreC = 30; // 배열 : 메모리상에서 연속적으로 나열된 상태 int scores[] = { 10, 20, 30 }; cout
2022.05.31 -
[C++] 15. sizeof()
#include using namespace std; void main() { int num = 10; //sizeof(크기를측정하고싶은것) cout
2022.05.31 -
[C++] 다중for문을 써서 별을 찍어보자
#include using namespace std; void main() { cout
2022.05.31