online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> // int, float, char 타입의 값을 출력하는 함수 void printValue(void*ptr, char type){ // void 포인터 ptr : 어떤 타입의 데이터도 가리킬 수 있음 // char type : 데이터의 타입을 구분하기 위한 문자 ('i', 'f', 'c') switch (type){ // 타입에 따라 분기 처리 case 'i': // 정수형(int)일 경우 printf("%d\n", *(int*)ptr); // void 형 포인터를 int형 포인터로 형 변환하여 역참조 break; case 'f': // 실수형(float)일 경우 printf("%f\n", *(float*)ptr); // void 형 포인터를 float형 포인터로 형 변환하여 역참조 break; case 'c': // 문자형(char)일 경우 printf("%c\n", *(char*)ptr); // void 형 포인터를 char형 포인터로 형 변환하여 역참조 break; } } int main(){ // 프로그램 시작점 int i = 23; // 정수형 변수 i 선언 및 23으로 초기화 float f = 4.5; // 실수형 변수 f 선언 및 4.5로 초기화 char c = 'z'; // 문자형 변수 c 선언 및 'z'로 초기화 printValue(&i, 'i'); // 정수형 변수 i의 주소와 타입 전달 printValue(&f, 'f'); // 실수형 변수 f의 주소와 타입 전달 printValue(&c, 'c'); // 문자형 변수 c의 주소와 타입 전달 return 0; // 프로그램 정상 종료 }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue