- #import<Foundation/Foundation.h>
- int main()
- {
- NSString *str = @"itcast"; //创建字符串
- char *name = "itcast";
- NSLog(@"%s",name);
- NSLog(@"%@",str);
- int age = 15;
- int no = 5;
- NSString *name1 = @"jack";
- NSString *newStr = [NSString stringWithFormat:@"My age is %d and no is %d and name is %@",age,no,name1];//第二种创建方法
- NSLog(@"%@",newStr);
- // 计算字符串的个数,不是字符数
- int size = [name1 length];
- NSLog(@"%d",size);
- NSLog(@"%ld",[newStr length]);
- return 0 ;
- }
复制代码 |
|