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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:03:57+00:00 2026-06-19T03:03:57+00:00

EDIT: Ctrl-D terminates buffer in linux. Ctrl-Z in Windows. I should add I use

  • 0

EDIT:

Ctrl-D

terminates buffer in linux.

Ctrl-Z

in Windows.

I should add I use Linux. I use g++.

Now, I’m learning C++ by way of C++ Primer Edition 4.

In an example, this code is given:

#include <iostream>
    int main()
    {
        int sum = 0, value;
        // read till end-of-file, calculating a running total of all values read
        while (std::cin >> value)
            sum += value; // equivalent to sum = sum + value
        std::cout << "Sum is: " << sum << std::endl;
        return 0;
     }

Now, I enter “3 4 5 6”, and I press enter, all I get is a newline, like:

1 2 3 4 5
Blank line

No output at all.

I refuse to use concepts I haven’t learned yet, so far I know no cin.METHOD functions, so what’s the problem?

  • 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-19T03:03:58+00:00Added an answer on June 19, 2026 at 3:03 am

    Input and output are buffered. End the input to terminate the loop by pressing Ctrl+Z in the console.

    Or read from a file:

    echo '1 2 3 4 5' > foo.txt
    ./your-program < foo.txt
    

    Or read from standard input via a pipe:

    echo '1 2 3 4 5' | ./your-program
    

    or:

    ./your-program <<< '1 2 3 4 5'
    

    (Depending on the terminal emulator you’re using.)

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

Sidebar

Related Questions

Code: http://plnkr.co/edit/xPZM5E7tjYqlt5NIabIu?p=preview line-no:17 In this code if I use ctrl.$modelValue = nVal; instead of
I'm using ctrl + q very often to get to the last edit location.
There is a command in Visual Studio 2005 called Edit.SelectToLastGoBack (bound to Ctrl +
I am making a Windows Form in C#. I have a menustrip (File, Edit,
When I edit .aspx or .cshtml file in the Visual Studio and press Ctrl-F5
We all know Visual Studio's Edit > Format Document ( Ctrl + K ,
I want to be able to use a keyboard shortcut to edit my .emacs
Is there any way to stop an R program without error? For example I
I am using a html editor to edit content. Now i need to make
In Notepad++, I can use Ctrl + Shift + Up / Down to move

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.