online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> #include <stdlib.h> #include <time.h> int throwDice(); int getUserGuess(); void playGuessingGame(); int throwDice(){ return rand()%6+1; } int getUserGuess(){ //κ°’ μž…λ ₯ λ°›μŒ int guess; printf("μ£Όμ‚¬μœ„λ₯Ό 던져 λ‚˜μ˜¬ 숫자λ₯Ό λ§žν˜€λ³΄μ„Έμš”(1μ—μ„œ 6κΉŒμ§€):"); scanf("%d",&guess); return guess; } //do~whileλ¬Έ λŒ€μ‹  while문의 λ¬΄ν•œλ£¨ν”„λ‘œ μž‘μ„±ν•΄λ΄€μŠ΅λ‹ˆλ‹€. void playGuessingGame() { int userGuess, diceResult; while (1) { // λ¬΄ν•œ 루프 μ‹œμž‘ userGuess = getUserGuess(); // λ§€ λ°˜λ³΅λ§ˆλ‹€ μž…λ ₯ λ°›κΈ° // μž…λ ₯값이 0이면 반볡 μ’…λ£Œ if (userGuess == 0) { printf("κ²Œμž„μ„ μ’…λ£Œν•©λ‹ˆλ‹€.\n"); break; //μ™„μ „νžˆ λΉ μ Έλ‚˜κ° } if(!(userGuess >=1 && userGuess<=6)){ // (userGuess<1 || userGuess>6)μœΌλ‘œλ„ μ“Έ 수 있음 printf("잘λͺ» μž…λ ₯λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 1~6μ‚¬μ΄μ˜ 숫자둜 λ‹€μ‹œ μž…λ ₯ν•΄μ£Όμ„Έμš”.\n"); continue; //ν”„λ‘œκ·Έλž¨ μ’…λ£Œ ν•˜λŠ” 게 μ•„λ‹ˆλΌ λ‹€μ‹œ whileλ¬Έ μ•ˆμͺ½μœΌλ‘œμ˜¬λΌκ° } diceResult = throwDice(); printf("μ£Όμ‚¬μœ„ κ²°κ³Ό: %d\n", diceResult); if (userGuess == diceResult) { printf("μΆ•ν•˜ν•©λ‹ˆλ‹€! 숫자λ₯Ό λ§žμ·„μŠ΅λ‹ˆλ‹€.\n"); } else { printf("μ•„μ‰½μŠ΅λ‹ˆλ‹€. λ‹€μ‹œ μ‹œλ„ν•˜μ„Έμš”.\n"); } } } // do{ // userGuess=getUserGuess(); // diceResult=throwDice(); // printf("μ£Όμ‚¬μœ„ κ²°κ³Ό:%d\n",diceResult); // if(userGuess==diceResult){ // printf("μΆ•ν•˜ν•©λ‹ˆλ‹€!숫자λ₯Ό λ§žμ·„μŠ΅λ‹ˆλ‹€.\n"); // }else{ // printf("μ•„μ‰½μŠ΅λ‹ˆλ‹€.λ‹€μ‹œ μ‹œλ„ν•˜μ„Έμš”.\n"); // } // }while(userGuess != 0); // } int main(){ srand(time(NULL)); printf("μ£Όμ‚¬μœ„ 숫자 맞히기 κ²Œμž„μ„ μ‹œμž‘ν•©λ‹ˆλ‹€.\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