C + + Primer Fifth Edition, chapter eighth answer

Source: Internet
Author: User

8.1 8.2/** C + + primer exercise.* Test file.*/#include <iostream>using namespace Std;istream & Read_write (istre    Am &in) {//char cval;    int ival;    while (In>>ival) cout<<ival<< ";    In.clear (); return in;}        int main (int argc, char* argv[]) {read_write (CIN);    System ("pause"); return 0;} 8.3 read type mismatch, EOF, a system-level unrecoverable state occurs. 8.4/** C + + primer exercise.* Test file.*/#include <iostream> #include <fstream> #include <vector>#    Include <string>using namespace Std;int main (int argc, char* argv[]) {string sval;    Vector<string> Svec;    Ifstream in (* (argv+1));            if (in) {while (Getline (In,sval)) {svec.push_back (sval);        cout<<sval<<endl;        }}else{cerr<< "Can not open:" + string (* (argv+1));    return-1;    } for (unsigned int i=0;i<svec.size (); ++i) {cout<<svec[i]<<endl;    } system ("Pause"); return 0;}8.5/** C + + primer exercise.* Test file.*/#include <iostream> #include <fstream> #include <vector>#    Include <string>using namespace Std;int main (int argc, char* argv[]) {string sval;    Vector<string> Svec;    Ifstream in (* (argv+1));            if (in) {while (in>>sval) {svec.push_back (sval);        cout<<sval<<endl;        }}else{cerr<< "Can not open:" + string (* (argv+1));    return-1;    } for (unsigned int i=0;i<svec.size (); ++i) {cout<<svec[i]<<endl;    } system ("Pause"); return 0;}

C + + Primer Fifth Edition, chapter eighth answer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.