Receiving the error Cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
On this line of the code
char* pos = strrchr (szPathName, '/');
The full code method for it is here;
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString * path = [[NSBundle mainBundle] pathForResource: @"fd" ofType: @"dat"];
NSData* image = [NSData dataWithContentsOfFile:path];
const char* szPathName = [path UTF8String];
char* pos = strrchr (szPathName, '/');
*pos = 0;
if (CreateFaceFatted(szPathName) == 0)
{
NSLog(@"Init Dictionary failed");
}
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
? I'm not familiar with that. – JohnFilleaustrrchr
will return aconst char*
if the input is aconst char*
, and achar *
if the input is achar *
. Any way to getszPathName
as achar *
instead ofconst char*
automatically? If not, copy[path UTF8String]
to a dynamically allocatedchar *
. Or find some way to usestd::string
instead, which would be preferred. – JohnFilleau