Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
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
29 30
Tags more
Archives
Today
Total
관리 메뉴

난 정말 최고야 멋있어

C/C++ 전처리기에서의 #,## 본문

카테고리 없음

C/C++ 전처리기에서의 #,##

n00bh4cker 2020. 4. 14. 13:58
#include <iostream>
#include <typeinfo>
#define cat(a,b) (a##b)
#define str(a) #a
using namespace std;
int main()
{
	int hello = 3;
	cat(hel, lo) = 7;
	cout << hello << endl;
	cout << str(hello) << endl;
	cout << typeid(str(hello)).name() << endl;
	return 0;
}

결과 

7
hello
char const [6]

 

## 은 입력받은 것들을 이어주는 역할

# 은 문자열(const char*)로 치환해주는 역할을 한다