강의

멘토링

커뮤니티

Inflearn Community Q&A

chan99344728's profile image
chan99344728

asked

[MMORPG Game Development with C++ and Unreal Series] Part 1: Introduction to C++ Programming

Pointers vs Arrays

문자열 출력의 경우

Written on

·

463

0

안녕하세요

B는 data영역에 있는 문자열의 시작 주소를 저장하는데

그렇다면 B를 출력하면 주소값을 출력해야 하는거 아닌가요?

 

A의 상황도 같은 상황입니다.

c++

Answer 1

0

Rookiss님의 프로필 이미지
Rookiss
Instructor

cout이 char*에 대해선 단순 주소를 출력하지 않고,
문자열로 인식해서 0을 만날 때까지 문자를 출력하도록 overloading 되어 있습니다.
주소를 출력하려면 (long long) 캐스팅으로 int64 변환을 해주시면 됩니다. (32비트라면 unsigned int)

chan99344728's profile image
chan99344728

asked

Ask a question