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 / Tier 2, array of char/string

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 4th Dec 2017 13:47
Hello I have converted an app to Tier 2, most things are running fine, except for my strings.

When I retrieve a string from GetNetworkMessageString(), I need to store it, in say Detected_IP[element].

How do I declare an array of 34 elements that can store strings from GetNetworkMessage or a returned IP address from GetSocketRemoteIP()?

Have a nice day! And thanks for looking.
13/0
Westa
13
Years of Service
User Offline
Joined: 28th Oct 2011
Location:
Posted: 5th Dec 2017 04:13
Have a look at std::vector its a wrapper for arrays the will do want you need and does not require you to define the number of elements in advance.

std::vector<std::string> myListOfStrings;
myListOfStrings = {"item1", "item2","item3", "etc.."};

or

myListOfStrings .push_back("item4");
myListOfStrings .push_back("item5");
myListOfStrings .push_back("item6");

and to reset the list:

myListOfStrings .clear();

Westa
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 7th Dec 2017 11:09
Thanks Westa My problem was elsewhere, I had to NULL terminate strings and I had some wrong accessing of arrays
13/0

Login to post a reply

Server time is: 2024-11-24 06:37:03
Your offset time is: 2024-11-24 06:37:03