Archive for May 10, 2008

Basic input/output

Posted in Tech yourself C++ (in 5 years) with tags , , on May 10, 2008 by Baltazaar

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;
}