Thread: help me with this code [beginner]

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    82

    help me with this code [beginner]

    whats wrong with this code?? :\ why it is not working properly??

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        string name;
        string name2;
    
        cout << "Enter Name " ;
    
        cin >> name;
        cin.ignore('\n');
        getline (cin, name2);
        cout << "name 1 :" << name << "\n name 2: " << name2 ;
    
        return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What is it doing wrong? Have you looked at the documentation for ignore()?

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A beginner's code, need suggestion
    By sumitsatsangi in forum C++ Programming
    Replies: 7
    Last Post: 01-21-2012, 06:00 AM
  2. Beginner has problem。Can anyone have a look at my code?
    By smartfish in forum C Programming
    Replies: 12
    Last Post: 04-24-2011, 08:15 PM
  3. Problem with beginner code... please help
    By rkrajnov in forum C Programming
    Replies: 2
    Last Post: 09-25-2010, 11:47 PM
  4. beginner here need help with an array code
    By Ohshtdude in forum C++ Programming
    Replies: 6
    Last Post: 02-01-2009, 05:42 PM
  5. Code is hanging - Very simple C (Beginner)
    By pc_doctor in forum C Programming
    Replies: 10
    Last Post: 10-29-2007, 05:05 PM