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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:23:20+00:00 2026-06-17T07:23:20+00:00

Lets look at the following code: int main(void) { char c; while ((c =

  • 0

Lets look at the following code:

int main(void)
{
             char c;

             while ((c = getchar()) != EOF)
                     putchar(c);

             return (0);
 }

This program echo’s back the characters, only after a new line is passed as a character.
I tried directly reading using the read system call and passing len as 1, it still reads only when a new line is passed. I have 2 questions here: Who has implemented this optimization, is it the kernel or the terminal/shell?

Secondly, who is echoing back the characters on the first place, that is on the first press itself. Does terminal/shell play any role in the entire execution of this program?

  • 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-17T07:23:21+00:00Added an answer on June 17, 2026 at 7:23 am

    The shell is irrelevant. The tty into which you type (assuming it is not in raw mode, and echoing is enabled ) displays the characters as you type them, but does not pass them to the process until after you type enter. It handles all backspaces and editing etc, and your process never sees those. When you hit enter, the tty passes the entered line to the process.

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

Sidebar

Related Questions

Let's look at the following piece of code which I unintentionally wrote: void test
Let's look at the simple Java code in the following snippet: public class Main
Taking a look at the following code: $this->input->post('title', FALSE); I have manually disabled XSS
Lets take a look at the following code: mongodb.js var mongo = require('mongodb') ,
Lets look at the following example: public class BothPaintAndPrintable implements Paintable,Printable{ public void print()
Let's look at the following Go code: package main import "fmt" type Vertex struct
Let's have a look at the following Java code. public class Main { public
Let's look at the following code snippet in Java. package division; import java.math.BigDecimal; final
I have multiple tables in a MySQL database. Lets say they look like this:
Let's look at this code: IList<IHouseAnnouncement> list = new List<IHouseAnnouncement>(); var table = adapter.GetData();

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.