Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Programming
- loop
- 오류
- Class
- 기초
- 재귀
- dynamic
- W3Schools
- Unreal Engine 5
- w3school
- Algorithm
- 문제풀이
- C#
- 프로그래밍
- 백준
- Basic
- UE5
- python
- String
- parameter
- DP
- dfs
- guide
- github
- Unity
- Material
- 파이썬
- 시작해요 언리얼 2022
- Tutorial
- c++
Archives
- Today
- Total
행복한 개구리
C++ Tutorial - Pointers / Modify Pointers 본문

포인터 값 적용하기
당신은 포인터의 값을 변경할 수 있습니다. 하지만 이것은 원래 변수의 값까지도 변경시킨다는 것을 주의하세요:
예시
#include <iostream>
using namespace std;
int main() {
string food = "Pizza";
string* ptr = &food;
// food의 값 출력
cout << food << "\n";
// food의 메모리 주소값 출력
cout << &food << "\n";
// food의 메모리 주소에 접근하여 값을 출력
cout << *ptr << "\n";
// 포인터의 값 변경
*ptr = "Hamburger";
// 새로운 값의 포인터 출력
cout << *ptr << "\n";
// food 변수의 새로운 값을 출력
cout << food;
}

'C++ > 공부내용' 카테고리의 다른 글
| C++ Functions - Functions Parameters / Parameters, Arguments (0) | 2022.06.27 |
|---|---|
| C++ Functions - Functions (0) | 2022.06.27 |
| C++ Tutorial - Pointers / Dereferencing (0) | 2022.06.23 |
| C++ Tutorial - Pointers / Create Pointers (0) | 2022.06.23 |
| C++ Tutorial - References / Memory Address (0) | 2022.06.23 |