1. cin vs getline vs cin.getline

    cin vs getline vs cin.getline

    Case with '\n'

    cin

    drop all `'\n'` except last one (just leave it in the buffer,won't get it and will finally drop it).
    

    getline

    read until `'\n'` and replace `'\n'` with `'\0'`.
    

    cin.getline

    same with getline, replace `'\n'` with `'\0'`.
    
    but …
    Tagged as : C++ program

Pages