String getline() problem

I've written the following code in order to get user input until the user writes a character previously entered:
1
2
3
4
5
6
7
8
9
10
11
    string str, temp;
    
    char c;
    
    cout << "Insert the character that ends the input:" << endl;
    
    cin >> c;
    
    cout << "Insert the string:" << endl;
    
    getline(cin, str, c);


Now, why doesn't the input end if I write the following?

Insert the character that ends the input:
}
Insert the string:
asdf
}
do it}
damn}
This is one of the hazards of mixing the extraction operator>> with getline() the extraction operator doesn't extract the end of line character so you will need to remove that character.
Topic archived. No new replies allowed.