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 7575505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:42:21+00:00 2026-05-30T16:42:21+00:00

Was wondering how you would be able to test the input that is saved

  • 0

Was wondering how you would be able to test the input that is saved in an char array like…

   char input[INPUT_SIZE];

And using

fgets(input,INPUT_SIZE,stdin);

To get the input from the user but was wondering how i could use a if statement to test if the users input has been for example
ctrl + d or any ctrl + anykey?

I tryed using there ascci value like this.. is an example to test for ctrl d

  if(result = 'EOT') {printf("EOT");}

Result is a char array aswell.

  • 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-05-30T16:42:22+00:00Added an answer on May 30, 2026 at 4:42 pm

    You can only test Ctrl+d as your read returning EOF, see the manual of your read to have more info on this, but generally it returns 0. Same goes for Ctrl+c, as both are sending signals to your program.

    For other Ctrl+key combinations, it highly depends on your system.

    On linux Ctrl+a and Ctrl+e in a shell or emacs will move you to the beginning or the end / beginning of the line respectively.

    The easiest to get what you want is to write a small program using read, unbuffered (see ioctl), with a 8-bytes buffer, and dump your read bytes each time you exit the read.

    int nbr;
    int i;
    char buf[8];
    
    nbr = 42;
    while (nbr > 0)
    {
      nbr = read(0, buf, 8);
      i = 0;
      while (i < nbr)
        printf("%x ", buf[i++]);
      printf("\n");
    }
    

    You will have the hex version of the ctrl+key received sequences. Likely to begin with \ESC or \033 (the escape character sequence). For example the arrow-up key looks like \033[A

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to find an element named 'test' with no
I was wondering if someone would be able to help me write a CQL
I was wondering if anyone would be able to help me convert the below
I was wondering, whether knockd http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki would be a good was to be able
I was just wondering which would be cheaper, using a try catch block for
In a C# app, I would like users to be able to enter search
I'm just wondering what htaccess mod rewrite regex would be able to redirect any
I am trying to test a rather horrible method that passes its input parameter
I have some code that raises PropertyChanged events and I would like to be
I was wondering how I would be able to hide a post with jquery.

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.