[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scanf does not properly pass characters
From: |
igorland |
Subject: |
Re: scanf does not properly pass characters |
Date: |
Sat, 25 Jan 2014 08:25:52 -0800 (PST) |
Markus. Thank you! I have noticed now. Then I faced another issue: converting
the C string to NSString.
Code:
// First program
#import <Foundation/Foundation.h>
int main (int argc, const char* argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
char nameC[50];
NSLog(@"ENter your name: ");
scanf("%s", &nameC);
NSString* nameS = [NSString stringWithCString:nameC
encoding:NSUTF8StringEncoding];
NSLog(@"Character Name is: %s", nameC);
NSLog(@"NSString Name is: %s", nameS);
[pool drain];
return 0;
}
Result:
<http://gnustep.8.n7.nabble.com/file/n36653/objc1.jpg>
Thanks a lot!
--
View this message in context:
http://gnustep.8.n7.nabble.com/scanf-does-not-properly-pass-characters-tp36651p36653.html
Sent from the GNUstep - General mailing list archive at Nabble.com.