3

我在 Windows7 上通过 cygwin 使用 gcc4 和 gdb 进行了 eclipse June CDT。我似乎无法从控制台获取输入。我四处搜索,它可能与 Eclipse 的 EOF 有关,这可以通过在运行/调试配置中取消选中“将进程输入和输出连接到终端”来解决。但我似乎无法取消选中它。

任何人都可以建议解决此问题的最佳方法。

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

void menu();
int main(void) {


    menu();
    return 0;
}


void menu()
{
    int i=0;
     printf(" \n1. Push to Queue");
         printf(" \n2. Pop from Queue");
         printf(" \n3. Display Data of Queue");
         printf(" \n4. Exit\n");
         while(1)
         {
              printf(" \nChoose Option: ");
              scanf("%d",&i);
              switch(i)
              {
                    case 1:
                    {
                         int value;
                         printf("\nEnter a valueber to push into Queue: ");
                         scanf("%d",&value);
                        // push(value);
                        // display();
                         break;
                    }
                    case 2:
                    {
                        // delQueue();
                        // display();
                         break;
                    }
                    case 3:
                    {
                        // display();
                         break;
                    }
                    case 4:
                    {
                         exit(0);
                    }
                    default:
                    {
                         printf("\nwrong choice for operation");
                    }
              }
         }

}
4

2 回答 2

1

找到了一对相关的相关SO问题:

长话短说,他们说 cygwin 与其他操作系统相比被视为“不同”的缓冲区,因此控制台不像(可能)应该那样“交互”。一些解决方案建议显式刷新缓冲区,而其他解决方案则提供配置选项。

于 2013-03-29T21:49:30.317 回答
1

您需要为 Eclipse 配置命令行参数:在运行配置>参数下

在这里阅读

还可以考虑使用 Ant 作为构建脚本。从长远来看效果更好。

于 2013-03-29T18:02:47.723 回答