I need variable charSize. How do I do this in objective-c:
char *bufferData = new char[charSize]; //c++ notation
thx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You use
malloc:(Technically the
sizeof(char)isn’t necessary since chars are always of size 1, but I like to include it anyway so that it looks “wrong” if I accidentally do a malloc without a size.)But depending on what you’re doing, you might want to look into NSString or NSData, the Cocoa classes for dealing with text and binary data, respectively. The rest of the Cocoa framework generally uses those.