Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:35:24+00:00 2026-06-03T05:35:24+00:00

I am running a C program in Code :: Blocks in windows XP. I

  • 0

I am running a C program in Code :: Blocks in windows XP.
I am getting an error as

"drawing operation is attempeted when there was no current window"

What might cause this and how can I solve it?
My code is as follows:

#include <stdio.h>
#include <conio.h>
static int get_code(void);
// System dependent key codes
enum
{
    KEY_ESC     = 27,
    ARROW_UP    = 256 + 72,
    ARROW_DOWN  = 256 + 80,
    ARROW_LEFT  = 256 + 75,
    ARROW_RIGHT = 256 + 77
};
int main(void)
{
    int ch;
    puts("Press arrow keys, escape key + enter to exit:");
    while (( ch = get_code()) != KEY_ESC )
    {
        switch (ch)
        {
        case ARROW_UP:
            printf("UP\n");
            break;
        case ARROW_DOWN:
            printf("DOWN\n");
            break;
        case ARROW_LEFT:
            printf("LEFT\n");
            break;
        case ARROW_RIGHT:
            printf("RIGHT\n");
            break;
        }
    }
    getchar();   // wait
    return 0;
}
static int get_code(void)
{
    int ch = getch();    // Error happens here
    if (ch == 0 || ch == 224)
        ch = 256 + getch();
    return ch;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:35:26+00:00Added an answer on June 3, 2026 at 5:35 am

    the α came from the getche() input, it prompts the user for input and when the user press a key then enter it echos that key on the standard output “screen” and since the arrows are non-printable keys that’s what happened you can do something like like this:

    switch (ch)
            {
            case ARROW_UP:
                printf("\bUP\n");
                break;
            case ARROW_DOWN:
                printf("\bDOWN\n");
                break;
            case ARROW_LEFT:
                printf("\bLEFT\n");
                break;
            case ARROW_RIGHT:
                printf("\bRIGHT\n");
                break;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I am running below code in Code::Blocks in Windows OS. I used to
I am running a program and want to see what its return code is
While running a program I've written in assembly, I get Illegal instruction error. Is
When I am running this program I am getting warning array subscript has type
Hi I have a problem building a program in Code::Blocks. The problem is when
I am looking for a method to monitor a running program that I have
I'd like to break out of the currently running program and be dropped back
I am running a program, in the end I ran a GUI that writes
I'm running a program to list info of all files stored in folder. I
I have a .NET CF program (running on a Smartphone) and I have written

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.