My .mm file -
std::string argv([argumentString UTF8String]);
int x = obj.zmain(argumentCount,argv);
obj is object of type ZMain.
My .cpp file -
int ZMain::zmain(int argc,std::string argv) {
std::istringstream iss(argv);
std::string s;
char *paramArray[argc];
int i=0;
while ( getline( iss, s, ' ' ) ) {
strcpy(paramArray[i],s.c_str());
std::cout<<paramArray[i]<<std::endl;
i++;
}
return 0;
}
I get error "EXC_BAD_ACCESS" sometimes inside the loop, sometimes before the loop and sometimes after the loop. What would be the problem?