CCArray->addObject with string.

CCArray->addObject with string.
0.0 0



My code keeps giving me errors. What am I doing wrong?

CCArray *data;
data = CCArray::createWithCapacity(300);
char gg1[50];
char gg2[50];
data->addObject((CCObject*)gg2); // I get error here

I tried using concatenated strings for my purpose but it was too slow.


I ended up using:

vector data;



Looks like you are trying to cast a char array to a CCObject pointer.
Char array does not inherit from CCObject so I’m not surprised this errored.


You should use CCString.


How can I use CCString?


CCString* ccstr = CCString::create(“abc”);


Alright, but here’s the thing.

I want to take this array, concatenate its elements into ONE string, and use this string as parameter in a post request.

I did this:

string conc;
conc = “”;

for (int i = 0; i < ccstr.size(); i+) {
conc = conc

And the conc string is populated correctly. However, when I try to put it in the request, like so:

char postData[50000];
sprintf(postData, “param=%s”, conc.c_str());

I get an error.

Can someone help me here, I’m playing syntaxial gymnastics with two cruches.


You can do it like that:
char* postData = (std::string(“param=”) + conc).c_str();