Thread: Cin.getline skip data

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    2

    Question Cin.getline skip data

    Record is
    char FirstName[25];
    char Address[40];
    int Age;

    cout<<"enter first: ";
    cin>>Firstname;

    cout<<"enter address: "<<endl;
    cin.getline(address, 60);

    cout<<"enter age: ";
    cin>>age;

    output:
    enter first: MyName
    enter address:
    enter age: 11

    Problem: After entering firstname, I don't get a chance to enter address when it already skip to getting my age.

    What could be the problem? How do I solve this? Thanks.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    scroll up to top of page.....
    look right....
    click button that says search...

    be safe in the knowledge that this question gets answered just about every day!
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    cin.ignore(80, '\n'); should soak up enough stray junk.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simultaneously waiting for data on FIFO and UDP using select call
    By yogesh3073 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-05-2007, 09:53 AM
  2. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  3. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-28-2005, 12:59 AM
  4. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 03:22 PM
  5. Replies: 1
    Last Post: 07-31-2002, 11:35 AM