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.

Dark GDK / need a strcat() replacement

Author
Message
Mr Snuggles
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 29th Mar 2005 15:17
For some reason I had the idea that I would be able to save the directory I keep all of my media in in a char array and use that with strcat() to load objects so I would only have to type out the filename each time I loaded the object instead of the whole directory. But I forgot that strcat() alters the directory string when it's used. Is there a similar function I can use that appends one string to another and returns the result, but doesn't alter the input string?

Thanks in advance.

ooo isn't that precious
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 29th Mar 2005 15:29
If you use a STL string, I believe you can simply do:

std::string result = rootString + extraString;

You should probably double check with a C++ reference though as Im not 100% sure about this. However I think using STL string will make string manipulation easier for you in general.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Mar 2005 22:33
Yay! An STL user. This is one way (the better way) to do it.

An alternative, if you want to use non-C++ techniques:


*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 30th Mar 2005 00:39
lol
Mr Snuggles
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 30th Mar 2005 12:41
I'm looking for a nice, neat function that takes two char strings as input and returns a char string without actually altering either inputs.

ooo isn't that precious
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Mar 2005 21:27
Then just convert the C code above to a function



You still need to remember to free the returned string when you are done with it

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Mr Snuggles
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 31st Mar 2005 00:08
M'kay, thank you. ^_^

ooo isn't that precious

Login to post a reply

Server time is: 2024-03-29 13:18:46
Your offset time is: 2024-03-29 13:18:46