Jump to content
  • Advertisement
Sign in to follow this  

Noob objective c question (char arrays?)

This topic is 2918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a c++ programmer trying to pick up objective c. I'm going through some rough tutorials and want to print out some exception info:

printf( "%s: %s\n", [[e name] cString], [[e reason] cString] );

This leaves me with a warning about cString being depricated. I've been looking into the new way to do it, which appears to be NSString's getCString method. This takes in a buffer which is my problem. I'm not seeing how to make one at the moment. Here's my bad code:

char* buf[] = [[char[128] alloc] init];
char* buf2[] = [[char[128] alloc] init];
printf( "%s: %s\n", [[e name] getCString: buf], [[e reason] getCString: buf2] );

Clearly that's not right, but some google searches have only shown me to assign a char array to a string literal. Can someone correct me? Thanks!

EDIT: getCString actually takes a few more arguments, I know. That's not my issue though.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!