Using an output string stream is a handy way to convert a number to a string. However, what if you want to zero pad the number. Well, that’s where iomanip comes in handy. [code language="cpp"] #include <iomanip> // for setw, setfill #include <iostream> // for cout #include <sstream> // for ostringstream #include <string> // for [...]
Tag Archives | c++
C++ variable scope and the for loop
C++ allows you to re-use variables in nested scopes. A confusion arises sometimes, especially with those new to C++ rules, as to the variables at the top of a for loop. In a for loop, such as for (int i = 0; i < 2; i++) { … }, does the int i belong to [...]
Compiling C++ code on the command line
Quick instructions for compiling small C++ projects on the command line in bash.
Exceptional Cow?
I’ve been meaning to read Exceptional C++ for a while now. I went to check to see if my local library had it. I guess not:
How to parse command line arguments/parameters in C/C++/Perl/Python/Bash
This is the first of a series of simple posts highlighting programming idioms in several languages. One of the perils of programming in multiple languages regularly is that I sometimes forget simple things about a language. This series is intended as a reference for myself and others when switching back and forth between languages. There [...]