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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:23:40+00:00 2026-06-08T11:23:40+00:00

#include <iterator> #include <iostream> using namespace std; const int MAX_NAME_LENGTH=100; int main() { char

  • 0
#include <iterator>
#include <iostream>

using namespace std;

const int MAX_NAME_LENGTH=100;

int main()
{
    char name[MAX_NAME_LENGTH];

    cout<<"Introduce yourself\n";

    istream_iterator<char> eos;
    istream_iterator<char> isi(cin);

    for(int i=0;i<MAX_NAME_LENGTH; i++)
    {   
        if(isi == eos) 
        {
            name[i]=0; //Breakpoint is set here.
            break;
        }
        name[i] = *isi;
        isi++;
    }
    cout<<"Hi "<<name<<endl;

    system("pause");


}

When I type a name and press enter, this program still yields only a command prompt. After debugging, it turned out that the “if” is never reached; It seems to be that the end of stream (eos) is unreachable.

  1. Why the condition inside the “if” is always false?
  2. What is the simpliest way to fix my 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-08T11:23:45+00:00Added an answer on June 8, 2026 at 11:23 am

    The condition is satisfied when the end of file is reached, but the console has no natural EOF, so you need to tell it explicitly where the end is. You can enter the EOF character to the console by pressing ctrl+z in Windows or ctrl+d in Unix. Here’s a sample run that works:

    Input

    Chris
    ^Z
    

    Output

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

Sidebar

Related Questions

#include <iostream> using namespace std; int main() { int a, b, c, max; cout<<a=;
#include <iostream> #include <string.h> using namespace std; int main() { int e=0; int b=0;
using the following code: #include<iostream> #include<vector> using namespace std; int main() { vector<int> ivec;
i have written a sample program.below: #include<iostream> #include<string> #include<set> using namespace std; int main()
While I use iterator like this , //include header files using namespace std; int
I compiled the following example: #include <iostream> #include <iterator> using namespace std; class myiterator
In my main.cpp: using namespace std; #include <cstdlib> #include <iostream> #include <set> #include <string>
#include <list> #include <set> #include <iterator> #include <algorithm> using namespace std; class MyContainer {
#include <iostream> #include <tuple> int main(){ auto bt=std::make_tuple(std::tuple<>(),std::tuple<std::tuple<>>()); //Line 1 auto bt2=std::make_tuple(std::tuple<>(),std::tuple<>()); //Line 2
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <functional> #include <deque> using namespace

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.