NSlog和printf的区别

//NSlog和printf的区别,简单的给大家交流一下,若有错误,请指出哦,不胜感激

//1.NSLog会自动换行,不需要添加换行符,printf需要添加\n换行符

//2.NSLog会自动加上项目工程名、时间和进程信息,而printf仅输出要输出的信息,不会添加任何额外的东西。

//3.输入类型有区别:NSLog期待NSString*,而printf期待const char *。

//4.NSLog支持%@去打印一个对象类型,而printf则不支持

/*运行结果如下:

 2016-01-26 09:50:57.188 1[961:27642] Trust yourself,you are the best!

 Trust yourself,you are the best!

 Trust yourself,you are the best!Program ended with exit code: 0

 */

#import <Foundation/Foundation.h>

 

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        

        NSLog(@"Trust yourself,you are the best!");//未添加换行符

        printf("Trust yourself,you are the best!\n");//添加换行符

        printf("Trust yourself,you are the best!");//未添加换行符

    }

    return 0;

}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值