/* cstring2.cpp * Demonstrates using getline function */ #include #include using namespace std; int main(int argc, char *argv[]) { const int length = 81; char name[length]; char phone[length]; cout << "Please enter your name" << endl; // get a line from cin until '\n' or // length-1 (81-1) is reached, then adds '\0' // length should always correspond to the length of the array cin.getline(name, length); cout << "Please enter your phone" << endl; cin.getline(phone, length); cout << "your name is " << name << endl; cout << "your phone number is " << phone << endl; system("PAUSE"); return EXIT_SUCCESS; }