help me with this code [beginner]

This is a discussion on help me with this code [beginner] within the C++ Programming forums, part of the General Programming Boards category; whats wrong with this code?? :\ why it is not working properly?? Code: #include <iostream> #include <string> using namespace std; ...

  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
    2,905
    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, 09:15 PM
  3. Problem with beginner code... please help
    By rkrajnov in forum C Programming
    Replies: 2
    Last Post: 09-26-2010, 12:47 AM
  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, 06:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21