This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Creating a string from a character array

Hi all,

I would like to use the strcmp - string compare function, however don't know how to create a string from character array. Standard way would be something like this:

char arr[ ] = "Hello World";
string str(arr);

However the compiler doesn't like the type string. Is there a way to create a string that I could use such as in the following example?

if(strcmp("Hello World",str) == 0)
{do something}

Regards

Milan

Related