O'Reilly logo

Beginning C++ Programming by Richard Grimes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the project

Create a folder for the project and create a C++ file called email_parser.cpp. Since this application will read files and process strings, add includes for the appropriate libraries and add code to take the name of a file from the command-line:

    #include <iostream>     #include <fstream>     #include <string>      using namespace std;      void usage()     {         cout << "usage: email_parser file" << "n";         cout << "where file is the path to a file" << "n";     }      int main(int argc, char *argv[])     {         if (argc <= 1)         {             usage();             return 1;         }          ifstream stm;         stm.open(argv[1], ios_base::in);         if (!stm.is_open())         {             usage();             cout << "cannot open " << argv[1] << "n";             return 1;         }          return 0;     }

A header will have a name and a body. The body ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required