Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
C++ Programming

Converting a number to a String

 

Data types

Converting a number to a String

The easy way to do this is to concatenate an empty string.

The complicated way to do this is to box the number and use toString

The powerful way to do this is to use String.format method

1. [ C++ ] Number to String by adding an empty string


Big

When used with two strings the + operator just jams the two strings together. If one is a string and another a number then the number is turned into a string first. If both are numbers then + does add.

2. [ C++ ] Boxing the number


Big

3. [ C++ ] Creating a string


Big