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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:08:08+00:00 2026-05-23T15:08:08+00:00

Possible Duplicate: getline not asking for input? There is some unique thing happening in

  • 0

Possible Duplicate:
getline not asking for input?

There is some unique thing happening in my program.
Here are some set of commands :

 cout << "Enter the full name of student: ";  // cin name
 getline( cin , fullName );

 cout << "\nAge: ";  // cin age
 int age;
 cin >> age ;

cout << "\nFather's Name: ";  // cin father name
getline( cin , fatherName );

cout << "\nPermanent Address: ";  // cin permanent address
getline( cin , permanentAddress );

When i try to run this snippet along with the whole code.The output program works like :

enter image description here

output:

Enter the full name of student:
Age: 20

Father's Name:
Permanent Address: xyz

If you notice ,the program didn’t ask me the full name and went on directly to ask me the age.Then it skips the father’s name also and asks the permanent address.
What could be the reason for this ?

It is difficult for me to post the whole code because it is too large.

  • 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-23T15:08:08+00:00Added an answer on May 23, 2026 at 3:08 pm

    Since you have not posted any code. I am going to take a guess.

    A common problem while using getline with cin is getline does not ignore leading whitespace characters.

    If getline is used after cin >>, the getline() sees this newline character as leading whitespace, and it just stops reading any further.

    How to resolve it?

    Call cin.ignore() before calling getline()

    Or

    make a dummy call getline() to consume the trailing newline character from the cin >>

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

Sidebar

Related Questions

Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: or is not valid C++ : why does this code compile ?
Possible Duplicate: string1 >= string2 not implemented in Linq to SQL, any workarround? To
Possible Duplicate: Why does “abcd”.StartsWith(“”) return true? Whilst debugging through some code I found
Possible Duplicate: Need help with getline() In the following code, my getline is skipped
Possible Duplicate: Why do I see a double variable initialized to some value like
Possible Duplicate: Ruby: Any gems for threadpooling? Is there a better ruby lib thread
Possible Duplicate: Image Button in BlackBerry Is there a way to have a picture
Possible Duplicate: PHP class instantiation. To use or not to use the parenthesis? I'm
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the

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.