3

I have eclipse June CDT with gcc4 and gdb via cygwin on Windows7. I can't seem to taken input from the console. I searched around and it might be related to EOF for eclipse which might be resolved by unchecking "Connect process input & output to a terminal" in the Run/Debug configuration. But I can't seem to uncheck it.

Can anyone suggest best way to fix this issue.

#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");
                    }
              }
         }

}
5
  • Are you referring to a cygwin "console" (like a terminal session) or the "Console" View (tab) inside Eclipse? Like can you get input from Eclipse's Console View? Commented Mar 28, 2013 at 8:22
  • Eclipse console view. Commented Mar 29, 2013 at 3:40
  • So you can type in there, but when you hit "Enter" or whatnot it does not read into your program? I've used Eclipse CDT on MacOSX and had no problem with console input. Is this only a problem when trying to send "EOF"? Does "Ctrl-D" not work (to send EOF) when the Console Tab has focus? Commented Mar 29, 2013 at 4:47
  • Could you try posting a small example of the code that isn't working? (Or can you verify that it works in other console environments?) Commented Mar 29, 2013 at 4:48
  • When i run it. I see blank screen in console view. It doesn't event print the menu. Ctrl-D doesnt do anything. If i hit enter it keep going on new line. When i do Ctrl-Z it exits and prints the menu. Commented Mar 29, 2013 at 17:36

2 Answers 2

1

You need to configure the command line arguments for Eclipse: Under Run configurations>Arguments

Read here

Also consider using Ant as a build script. Works better in the long run.

Sign up to request clarification or add additional context in comments.

Comments

1

Found a pair of relevant related SO questions:

Long story short, they are saying that cygwin is treated "differently" as a buffer compared with other OS's, and because of this the console is not as "interactive" as it (probably) should be. Some solutions recommend an explicit flush of the buffer, while others offer configuration options.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.