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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:50:38+00:00 2026-05-26T04:50:38+00:00

I mam trying to complete a college assignment in C++ and am having trouble

  • 0

I mam trying to complete a college assignment in C++ and am having trouble with what should be a very basic operation. I am trying to read a string of characters from the keyboard. This is the relevant code:

  string t;
  cout << endl << "Enter title to search for: ";
  getline(cin, t, '\n');  

I understand, that the last line is supposed to read the input buffer (cin , in this instance) and store the character in the ‘t’ string until it reaches a new line character and then continue the program flow.

However, when I run my code in XCode, it just sort of jumps over the getline function and treats ‘t’ as an empty string.

What’s going on? I tried using cin >> t but that just read characters forever – Why cant I get this to behave?

  • 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-26T04:50:39+00:00Added an answer on May 26, 2026 at 4:50 am

    The reason that the input operation apparently is skipped, is most probably (that means, ignoring possible peculiarities of a bugsy XCode IDE) that you have performed some input earlier and left a newline in the input buffer.

    To fix that, make sure that you have emptied the input buffer after each input operation that logically should consume a line of input.

    One easy way is to always use getline into a string, and then use e.g. an istringstream if you want to convert a number specification to number type.

    Cheers & hth.,

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

Sidebar

Related Questions

I would like to build a very basic daily sales report. I'm am trying
We were just trying out the Azure Storage Analytics Service, and something very unusual
I read in the contents of a file i then search for this string
I am trying to extract all substrings in a string that is between the
I'm am trying to make a three column layout for a website from an
I'm am trying to make a very simple rsync program with a user interface.
I'm trying to launch another process from a service (it's a console app that
I'm am trying to create a very simple WCF client application which will send
Hey all, I'm am trying to make a very interactive UI with lots of
I'm trying to write two types of stored procedures in PostgreSQL. From what I

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.