Basic input/output

Here is a snippet that reads two string variables from the console, and writes them out. Not much to write home about… Explanation follows.


#include <iostream>
#include <string>

using namespace std; //This is not pretty in global namespace scope, but we’ll learn…

int main(){

string fname, lname;
cout <> fname;
cout <> lname;

// Output to console:
cout << “Hello ” << fname << ” ” << lname << “!” << endl;

return 0;
}

Leave a Reply