vendredi 30 mars 2018

cin.get() function in C++

I have been studying c++ and came across the code below. I dont understand why they have to use the get(c) in "cin.get(straddress, sizeof(straddress), fdelim).get(c)". The code works just fine without this get(c). Can someone enlighten me on the use of get(c)? The purpose of the program is to read data of mixed type.

const char fdelim = '\t';
char straddress[256];
int zip;
char c;

cout << "Enter a record of data:  ";
cin.get(straddress, sizeof(straddress), fdelim).get(c) >> zip;
cout << "\nStreet address :   " << straddress << endl;
cout << "\nZip/Postal code:   " << zip << endl;

Aucun commentaire:

Enregistrer un commentaire