Can i do this:
AString = (String1 + "and" + String2);
??
Or is there an other way?
Thanks
Printable View
Can i do this:
AString = (String1 + "and" + String2);
??
Or is there an other way?
Thanks
You can't write it that way in C. C has a very basic concept of string type, and almost every manipulation on a string requires a function call. In this case, you need strcat() to "concatenate" two strings.
--
Mats
Not in C. To add strings together use strcat, and remember that you need to set enough space aside to hold the resulting string. Example:
Code:#include <stdio.h>
#include <string.h> // for strcat
int main()
{
char result[255] = {""};
char a[] = "String1";
char b[] = "String2";
strcat(result, a);
strcat(result, " and ");
strcat(result, b);
printf("%s", result);
getchar();
}