Thursday, March 29, 2012

(re)learning C++

I haven't really used C++ since my undergraduate days -- I've mostly worked in Java recently.  Feeling nostalgic, I decided to refresh these particular skills.  I'll be using the freely available C++ IDE called Code::Blocks (available at http://www.codeblocks.org/) and the tutorials at http://www.cplusplus.com/doc/tutorial/introduction/ (where Code::Blocks appears to be recommended above Dev-C++).  Running the "Hello World" program was easy, but to stop the exiting immediately, I recommend adding an int "dummy" variable and a "cin" to the standard code, e.g.,

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  int pauseVariable;
  cout << "Hello World!" << endl;
  cout << "Type something and press Enter to continue..." << endl;
  cin >> pauseVariable;
  return 0;
}
P.S. Figured out syntax highlighting thanks to http://mlawire.blogspot.com/2009/07/blogger-syntax-highlighting.html except that (at the time of posting) "Edit HTML" is located under the Template menu in your Blogger dashboard.
P.P.S. Code::Blocks integrates nicely with the Simple and Fast Multimedia Library - http://www.sfml-dev.org/