Inputting characters using cin member function getline - C++ File Stream

C++ examples for File Stream:cin

Description

Inputting characters using cin member function getline

Demo Code

#include <iostream>

int main(int argc, const char *argv[]) {
    const int SIZE = 80;
    char buffer[SIZE];

    // input characters in buffer via cin function getline
    std::cout << "Enter a sentence:" << std::endl;
    std::cin.getline(buffer, SIZE);/*from w  ww  .j a v a2  s .  co m*/

    // display buffer contents
    std::cout << "\nThe sentence entered is:" << std::endl
              << buffer << std::endl;

    return 0;
}

Result


Related Tutorials