online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
// example7-1.c #pragma warning(disable:4996) #include <stdio.h> // printf, scanf #include <stdlib.h> // rand, srand #include <time.h> // time // 1~6 사이의 난수 반환 int throwDice(void) { return rand() % 6 + 1; } // 사용자로부터 0~6 사이의 정수를 입력받아 반환 // 0을 입력하면 게임 종료 int getUserGuess(void) { int guess; printf("주사위를 던져 나올 숫자를 맞혀보세요 (1~6, 종료는 0): "); scanf("%d", &guess); return guess; } // 게임 로직 void playGuessingGame(void) { int userGuess, diceResult; do { userGuess = getUserGuess(); if (userGuess == 0) { // 0 입력 시 반복 종료 break; } diceResult = throwDice(); printf("주사위 결과: %d\n", diceResult); if (userGuess == diceResult) { printf("축하합니다! 숫자를 맞혔습니다.\n\n"); } else { printf("아쉽습니다. 다시 시도하세요.\n\n"); } } while (userGuess != 0); } int main(void) { // 난수 초기화 srand((unsigned)time(NULL)); printf("===== 주사위 숫자 맞히기 게임을 시작합니다 =====\n\n"); playGuessingGame(); printf("===== 게임 종료 =====\n"); 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