//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;
}