環境は、BCC Developerです。
その箇所には、 '/* ☆ここが表示されません。 */' と書いてあります。
#include <DxLib.h> /* DxLib.h を含める */
// 関数のプロトタイプ宣言
int maxMinAns( int x, int y ); /* ある値に対して、大きいか小 */
/* さいか, 正解かを -1 or 1 or 0 */
/* で渡す関数 */
// Window の生成
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPewvInstance, LPSTR lpCmdLine, int CmdShow ) {
ChangeWindowMode( TRUE ); /* window の変更 */
SetMainWindowText( "数当てゲーム" );
if( DxLib_Init( ) == -1 ) /* 初期化 */
return -1;
// ユーザーが × ボタンを押しても自動的に終了しないようにする
// http://dixq.net/forum/viewtopic.php?f=3&t=10265
SetWindowUserCloseEnableFlag( FALSE );
/***************************変数宣言****************************/
int ans_rnd; /* 乱数を格納する変数 */
int input_val; /* 数字受付変数 */
int aray_test[ 10 ]; /* 配列に値を格納していく */
int aray_cnt = 0; /* カウント変数 */
int line_down = 30; /* 改行処理変数 */
int flg; /* 関数の戻り値格納変数 */
unsigned int clr = GetColor( 255, 255, 255 ); /* 白 */
LPSTR lpstr = ""; /* 文字格納変数 */
/////////////////////////////////////////////////////////////////
for( int x = 0; x < 10; x++ )
aray_test[ x ] = 0; /* 配列の初期化 */
// 1 ~ 9 を乱数で適当に取得する
do {
ans_rnd = ( int ) ( GetRand( 9 ) );
} while( ans_rnd == 0 );
SetDrawScreen( DX_SCREEN_BACK ); /* 描画先画面を裏画面にする */
lpstr = "~数当てゲーム~";
// ダブルバッファ
while( ScreenFlip( ) == 0 && ProcessMessage( ) == 0 &&
ClearDrawScreen( ) == 0 ) {
// 文字表示を確認できるようにするため
// キーが押されるまで待つ
WaitKey( );
DrawFormatString( 250, 30, clr, lpstr );
input_val = KeyInputNumber( 280, 60, 9, 1, true );
aray_test[ aray_cnt ] = input_val; /* 値を格納していく */
aray_cnt++; /* インクリメント */
// 格納した配列の出力
line_down = 30; /* 初期化 */
for( int x = 0; x < aray_cnt; x++ ) {
DrawFormatString( 5, 60 + line_down, clr,
"入力履歴 : ' %d ' です。", aray_test[ x ] );
/* 改行するため 30 づつインクリメント */
line_down += 30;
}
// 関数の実行
flg = maxMinAns( input_val, ans_rnd );
if( flg == -1 ) {
lpstr = "答えより大きいです!";
DrawFormatString( 250, 60, clr, lpstr );
} else if( flg == 1 ) {
lpstr = "答えより小さいです!";
DrawFormatString( 250, 60, clr, lpstr );
} else {
/* ☆ここが表示されません。 */
lpstr = "正解です!";
DrawFormatString( 250, 120, clr, lpstr );
lpstr = "何かキーを入力してください...終了します。";
DrawFormatString( 250, 150, clr, lpstr );
Sleep( 5000 ); /* 終了する前に 5 秒間まつ */
break;
}
// ESC キーの受付
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 ) break ;
}
// WaitKey( ); /* キーが押されるまで待つ */
DxLib_End( ); /* 終了処理 */
return 0;
}
int maxMinAns( int x, int y ) {
int flg;
if( y > x ) flg = 1; /* 乱数より大きいとき */
else if( y < x ) flg = -1; /* 乱数より小さいとき */
else flg = 0; /* 正解の時 */
x = flg;
return x;
}