Eclipse控制台不输出任何内容

时间:2019-12-25 05:43:46

标签: c eclipse

运行代码时,控制台不会输出任何内容。当我进入“调试为c应用程序模式”并进入应该打印东西的makeBoard()方法时,控制台上没有任何显示。如果控制台不工作,我将无法处理该项目。

每当我在int main(void)方法中仅使用makeBoard()运行代码时,控制台都会输出其预期内容。但是,当我将其他代码添加到int main(void)方法中时,控制台窗口中将不显示任何内容。

我对C和Eclipse IDE还是很陌生。我需要下载什么吗?

makeBoard()方法:

 void makeBoard(){
    printf("Row A: ");

    for(int i = 0; i< rowAcounter; i++)
    {
        printf("O");
    }
    printf("\n");

    printf("Row B: ");
    for(int i = 0; i< rowBcounter; i++)
        {
            printf("O");
        }

    printf("\n");
    printf("Row C: ");
    for(int i = 0; i< rowCcounter; i++)
        {
            printf("O");
        }
    printf("\n");
}

我完整的int main方法和程序的其余部分:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

void makeBoard();
void nextTurn(int player);
void prompt(int turn);
_Bool isGameOver();
void done(int currentTurn);
void test();
void update();

int rowAcounter = 3;
int rowBcounter = 5;
int rowCcounter = 8;
int currentPlayer = 0; // 0= player 1's turn, 1 
  = player 2's turn

char firstIn;
char secondIn;

_Bool flag = 0;

int main(void){
  makeBoard();

  while(isGameOver() == 0){
      prompt(currentPlayer);
      update();
      nextTurn(currentPlayer);
      if(flag == 1){
          break;
      }
      makeBoard();
  } 
  done(currentPlayer);
  return 0;
}

其余的代码:

void update(){

poll: scanf(" %c%c", &firstIn, &secondIn);
        int checkFirst = firstIn - 'A';
        if((checkFirst < 0) || (checkFirst > 2))
        {
            printf("\n Try again, you ape.");
            goto poll;
        }


        int checkSecond = secondIn - '0';
        if((checkSecond < 0 ) || (checkSecond > 8)){
            printf("\n Try again, you fricker.");
            goto poll;
        }
        else if(checkFirst == 0){       // the player chose row A
            if(checkSecond > 3){
                printf("\n Try again, you frick.");
                goto poll;
            }
            else{
                rowAcounter = rowAcounter - checkSecond;

            }
        }
        else if(checkFirst == 1){       // the player chose row B
            if(checkSecond > 5){
                printf("\n Try again, you headass.");
                goto poll;
            }
            else{
                rowBcounter = rowBcounter - checkSecond;

            }
        }
        else{                                       // the player chose row C
            if(checkSecond > 8)
            {
                printf("\n Try again!");
                goto poll;
            }
            else{
                rowCcounter = rowCcounter - checkSecond;

            }
        }

        if(isGameOver() == 1){
            flag = 1;
        }


 }


void nextTurn(int player){
if(player == 0){
    player = 1;
}else
  {
      player = 0;
  }
}

void prompt(int turn){
if(turn == 0){
    printf("Player 1, make your move:");
}
else{
    printf("Player 2, make your move:");
  }
}

_Bool isGameOver(){
if((rowAcounter == 0) && (rowBcounter == 0) && (rowCcounter == 0)){
    return 1;
}
else{
      return 0;
  }
}

void done(int currentTurn){
if(currentTurn == 0){
    puts("Player 1 wins!");
}
else{
      puts("Player 2 wins!");
  }
}

0 个答案:

没有答案