Hello,
My code keeps giving me errors. What am I doing wrong?
CCArray *data;
data = CCArray::createWithCapacity(300);
data~~>retain;
char gg1[50];
char gg2[50];
data~~>addObject((CCObject*)gg1);
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;
data.push_back(gg1);
data.push_back(gg2);
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.
CCString* ccstr = CCString::create(“abc”);
data->addObject(ccstr);
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 ccstr[i].c_str();
}
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();