Main Menu

Sponsored Links


Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

String Functions

You already know that sometimes char , int and double values and variable can be automatically converted to strings. But sometimes you need to convert them manually. For example, if you want to receive a concatenated string out of 2 integers, you cannot just use operator +, because this will be an operation between integers. You must convert them to strings first. You should use one of these functions to convert them manually using functions IntToString , CharToString and DoubleToString :

string sRes;

// the following statement will assign sRes "1+2.500000=3.5";

sRes = IntToString ( 1 ) +

CharToString ( '+' ) +

DoubleToString ( 2.5 ) +


You can also see from this example that it is legal in C++ to carry over a sentence to the next line. You just need to terminate it with semicolon.

Sometimes you may also want to convert a string value to int or double . Please keep in mind that not every string can be converted. For example string "one" cannot be converted to int or double . While it may sound like a number, it is not. Only strings which look like a number inside double quotes, like "123" or "0.28" , can be converted. You suppose to use functions StringToInt and StringToDouble to do this:

int iInt = StringToInt ( "123" ); // assign 123 to iInt

double dDouble = StringToDouble ( "12.3" ); // assign 12.3 to dDouble

If there is no conversion possible, then these functions return zero.

There are a couple of other functions to work with strings. These are StrLen , UpperCase and LowerCase . You can probably guess what they do by their name and example below:

// assign 4 to iLen because string "test" has 4 characters in it

int iLen = StrLen ( "test" );

// assign "TEST" to sUpperCased

string sUpperCased = UpperCase ( "test" );

// assign "test" to sLowerCased

string sLowerCased = LowedCase ( "TEST" );

Contents Previous Next

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi


Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat


Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.


Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal


read more news...