Hi,
As I am new to C/C++, I for some reason cannot get this simple concept.
If declare a string like:
char string[];
Shouldn't I be able to assign it a value later on? Like:
if(something is true)
string = "This is a string.";
else
string = "This is not a string.";
Can someone explain how to do this, please?
I have also tried it this way:
char *string[50];
then
if (something is true)
*string = "This is a string.";
else
*string = "This is not a string.";
which did work, but I also wanted to use strcat to combine two strings, but that doesn't work either. I guess there some fundamental simple thing that I don't get.
Thanks for the help,
Elena
As I am new to C/C++, I for some reason cannot get this simple concept.
If declare a string like:
char string[];
Shouldn't I be able to assign it a value later on? Like:
if(something is true)
string = "This is a string.";
else
string = "This is not a string.";
Can someone explain how to do this, please?
I have also tried it this way:
char *string[50];
then
if (something is true)
*string = "This is a string.";
else
*string = "This is not a string.";
which did work, but I also wanted to use strcat to combine two strings, but that doesn't work either. I guess there some fundamental simple thing that I don't get.
Thanks for the help,
Elena