Posted: 25th Oct 2011 6:00
I know the way in windows sdk ,but I think I should use a way which can cross platform.
Posted: 25th Oct 2011 9:16
Do you mean like CombinedString$ = String1$ + String2$
Posted: 25th Oct 2011 9:38
yes, but how to ?
Posted: 25th Oct 2011 9:57
I told you how.

CombinedString$ = String1$ + String2$

lolz
Posted: 25th Oct 2011 11:43
is it C++ sentence? or Basic?
Posted: 25th Oct 2011 12:19
Basic.
+ Code Snippet
string1$ = "Hello my name is "
string2$ = "baxslash"
combined$ = string1$ + string2$
do
    print(combined$)
    sync()
loop


This will print "Hello my name is baxslash" on the screen.
Posted: 25th Oct 2011 12:33
omg, I use c++ ,then what can I do ?
Posted: 25th Oct 2011 12:45
I'm no expert but I think it works quite similarly:
+ Code Snippet
string string1, string2, combined;
string1 = "Hello my name is ";
string2 = "baxslash";
combined = string1 + string2;


...although I don't use C++ I do use C# which is similar...
Posted: 25th Oct 2011 13:01
it doesn't work in C++.

any one else can help?
Posted: 25th Oct 2011 13:18
Try this? (Google search):
+ Code Snippet
#include <iostream.h>
#include <string.h>

void main()
{
   char testString[20];
   char testString2[10];
   strcpy(testString2,"World");
   strcpy(testString1,"Hello ");  // Copies first string
   strcat(testString1, testString2); // Concatinates the second string
}
Posted: 25th Oct 2011 13:39
baxslash,thank you.
the code which you post does work. I want know if strcpy is cross platform? I use it in windows , why I can also use it in iOS ?
Posted: 25th Oct 2011 13:51
I don't think so. You'd need to learn xcode I think.
Posted: 25th Oct 2011 14:25
I just used Xcode this year. I have used VS for 5 years . I am much familiar with it.
Posted: 25th Oct 2011 14:31
I just used Xcode this year. I have used VS for 5 years . I am much familiar with it.

Then you understand the differences between Xcode and C++ better than I do. I haven't used Xcode and have barely looked at C++...
Posted: 25th Oct 2011 15:39
actually , I just used Xcode in last month.
Posted: 25th Oct 2011 17:29
Hi

strcpy is standard C function, so it is available everywhere. Using strcpy and strcat works fine, but you have to be sure the strings you're joining are terminated with NULL '\0', otherwise your app can crash.

A safer option is the "n" variation of them: strncpy and strncat. The only difference from what baxslash told you is that you have to tell the number of characters of each string. So, using the same example:

+ Code Snippet
#include <iostream.h>
#include <string.h>

void main()
{
   char testString[20];
   char testString2[10];
   strncpy(testString2,"World" , 5);
   strncpy(testString1,"Hello ", 4);  // Copies first string
   strcat(testString1, testString2, 5); // Concatinates the second string
}



If you want to code on different platforms this is probably the best bet. C++ in other hand, can provide you String classes that makes this job easier. I believe Cocoa has NSString, but it is only used on Apple platforms (iOS and MacOS).

Cheers
Posted: 27th Oct 2011 1:15
So far the string commands (strcpy, strcat, strcmp, etc) work on all platforms, although bada 1.2 tried to get rid of them in favour of their own string class, so it is not guaranteed that they will always be cross platform.

AGK includes a uString class for tier 2 users that wraps lots of these string functions plus a few more, check out uString.h for a full list.