cin and cin.getline()

Discussion in 'C++' started by MartijnMulder, Sep 20, 2006.

  1. MartijnMulder

    MartijnMulder New Member

    Sep 20, 2006
    Likes Received:
    Trophy Points:
    First of all, greatings from Italy to everyone, and sorry for my bad english!!

    I have this problem with the instruction cin.getline that follow a simple cin instruction:

    #include <iostream>
    typedef char String20[20];
    using namespace std;
    int main(){
    int times;
    String20 name;
    cout << "How many times do you want to repet the loop?";
    cin >> times;  // this "cin" make the problem!!
    cout << endl;
    cout << "Insert your Name";
    cin.getline(name, 20);
    /* At this point the program don't stand by the input
        but it jumps to next instruction. Why ??
        What's the right way to resolve the problem?
    return 0;
    Thanks a lot!!

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice