I try to pass a NSString to a C++ function, but I only get the first letter. Here is the code:
#import <Foundation/Foundation.h>
#import <string>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString* objcString=@"test";
std::string cppString([objcString cStringUsingEncoding:NSUnicodeStringEncoding]);
NSLog(@"%@, %s",objcString, cppString.c_str()
);
}
return 0;
}
It gives me:
2013-03-05 10:22:15.362 TEST[1136:353] test, t
Thank for your time, have a good day.