2020년 9월 16일 수요일

C++ - Get Variable Name (변수명 가져오기)

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

#define GET_NAME(n) #n

int main() {

	int StageNumber = 1000;
	string str = GET_NAME(StageNumber);
	cout << str << endl;
	return 0;
}
결과 출력 : "StageNumber"

댓글 없음:

댓글 쓰기