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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:04:00+00:00 2026-05-24T19:04:00+00:00

I understand EOF and EOL but when I was reading this question (second part

  • 0

I understand EOF and EOL but when I was reading this question (second part of answer) and i got my concepts broken :
Specially the para :

It won’t stop taking input until it finds the end of file(cin uses
stdin, which is treated very much like a file
)

so i want to know when we do some thing like in c++ under windows :
std::cin>>int_var; , and we press enter , this end the input but according to reference link it should only stop taking input after hitting ctrl+z.

So i would love to know how std::*stream deal with EOF and EOL.

Second part:
please have a look at this example :

std::cin.getline(char_array_of_size_256 ,256);
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout << "artist is " << artist << endl;

If i remove std::cin.ignore() it simply stops taking input (which is known case) but when i keep it , it waits for a new input which is ended by '\n' . But it should simply clear up stream rather then waiting for any new input ending-up with ‘\n’.

Thanks for giving you time)

  • 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-24T19:04:00+00:00Added an answer on May 24, 2026 at 7:04 pm

    End-of-line and end-of-file are very different concepts.

    End-of-line is really just another input character (or character sequence) that can appear anywhere in an input stream. If you’re reading input one character at a time from a text stream, end-of-line simply means that you’ll see a new-line ('\n') character. Some input routines treat this character specially; for example, it tells getline to stop reading. (Other routines treat ' ' specially; there’s no fundamental difference.)

    Different operating systems use different conventions for marking the end of a line. On Linux and other Unix-like systems, the end of a line in a file is marked with a single ASCII linefeed (LF, ‘\n’) character. When reading from a keyboard, both LF and CR are typically mapped to '\n' (try typing either Enter, Control-J, or Control-M). On Windows, the end of a line in a file is marked with a CR–LF pair (\r\n). The C and C++ I/O systems (or the lower-level software they operate on top of) map all these markers to a single '\n' character, so your program doesn’t have to worry about all the possible variations.

    End-of-file is not a character, it’s a condition that says there are no more characters available to be read. Different things can trigger this condition. When you’re reading from a disk file, it’s just the physical end of the file. When you’re reading from a keyboard on Windows, control-Z denotes end-of-file; on Unix/Linux, it’s typically control-D (though it can be configured differently).

    (You’ll usually have an end-of-line (character sequence) just before end-of-file, but not always; input can sometimes end in an unterminated line, on some systems.)

    Different input routines have different ways of indicating that they’ve seen an end-of-file condition. Read the documentation for each one for the details.

    As for EOF, that’s a macro defined in <stdio.h> or <cstdio>. It expands to a negative integer constant (typically -1) that’s returned by some functions to indicate that they’ve reached an end-of-file condition.

    EDIT: For example, suppose you’re reading from a text file containing two lines:

    one
    two
    

    Let’s say you’re using C’s getchar(), getc(), or fgetc() function to read one character at a time. The values returned on successive calls will be:

    'o', 'n', 'e', '\n', 't', 'w', 'o', '\n', EOF
    

    Or, in numeric form (on a typical system):

    111, 110, 101, 10, 116, 119, 111, 10, -1
    

    Each '\n', or 10 (0x0a) is a new-line character read from the file. The final -1 is the value of EOF; this isn’t a character, but an indication that there are no more characters to be read.

    Higher-level input routines, like C’s fgets() and C++’s std::cin >> s or std::getline(std::cin, s), are built on top of this mechanism.

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

Sidebar

Related Questions

Pardon me, this really is a noob question but please understand that I do
( This question about refactoring F# code got me one down vote, but also
I understand that this is highly specific to the concrete application, but I'm just
I am trying to understand EOF and EOL, and how C++ iostream actually works.
This question is related to my previous question but you dont need to read
I understand this might be a very basic question. Windows Azure needs me to
I understand what System.WeakReference does, but what I can't seem to grasp is a
I understand the difference between String and StringBuilder ( StringBuilder being mutable) but is
I understand that they are both supposed to be small, but what are the
I haven't been able to find this anywhere (or I just don't understand it).

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.