Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / a little question: how to connect two strings together ?

Author
Message
halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 25th Oct 2011 06:00
I know the way in windows sdk ,but I think I should use a way which can cross platform.

give my best
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 25th Oct 2011 09:16
Do you mean like CombinedString$ = String1$ + String2$

My signature is NOT a moderator plaything! Stop changing it!
halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 25th Oct 2011 09:38
yes, but how to ?

give my best
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 25th Oct 2011 09:57
I told you how.

CombinedString$ = String1$ + String2$

lolz

My signature is NOT a moderator plaything! Stop changing it!
halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 25th Oct 2011 11:43
is it C++ sentence? or Basic?

give my best
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 12:19 Edited at: 25th Oct 2011 12:19
Basic.


This will print "Hello my name is baxslash" on the screen.

halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 25th Oct 2011 12:33
omg, I use c++ ,then what can I do ?

give my best
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 12:45
I'm no expert but I think it works quite similarly:


...although I don't use C++ I do use C# which is similar...

halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 25th Oct 2011 13:01
it doesn't work in C++.

any one else can help?

give my best
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 13:18
Try this? (Google search):


halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
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 ?

give my best
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 13:51
I don't think so. You'd need to learn xcode I think.

halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
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.

give my best
baxslash
Valued Member
Bronze Codemaster
18
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Oct 2011 14:31
Quote: "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++...

halley
14
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 25th Oct 2011 15:39
actually , I just used Xcode in last month.

give my best
MobileCreator
14
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
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:




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

----------
Paulo
http://www.mobilecreators.com
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th Oct 2011 01: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.

Login to post a reply

Server time is: 2025-08-08 14:36:57
Your offset time is: 2025-08-08 14:36:57