• IPHONE 开发 6 Object C 02 常用数据类型[整型浮点型,短长整型],数组(固定长度,变长)


    常用数据类型与c语言基本一样 难怪是c语言的超集

    1.整型 (int) 浮点型 (float, double)  短长整型(short, long)

      int,[float,double],[short,long]

      int i=0;

      float i=1.1;

      double i =2.2;

       short int i =200;

      long int i=11111111111111111112456L;

    1. //整型
    2.     int i = 100;
    3.     //浮点型
    4.     float f = 1.1;
    5.     //双浮点型
    6. double d = 2.2;
    7.     //短整型
    8.     short int si = 200;
    9.     //长整型
    10.     long long int ll = 123324123234123L;
    11.    
    12.    
    13.     //输出数据与内存中所占字节数
    14.     //整型
    15.     NSLog(@"i = %d size = %lu byte ",i, sizeof(i));
    16.     //浮点型
    17.     NSLog(@"f = %f size = %lu byte",f,sizeof(f));
    18.     //双浮点型
    19.     NSLog(@"d = %e size = %lu byte",d,sizeof(d));
    20.     //短整型
    21.     NSLog(@"si = %hi size = %lu byte",si,sizeof(si));
    22.     //长整型
    23. NSLog(@"ll = %lli size = %lu byte",ll,sizeof(si));

    2.字符串 NSString*  与  char*  
        NSString * str=@"string";

        char * chr="a1212231";

    1. NSString * str = @"MOMO";
    2.     char *c = "15810463139";
    3.     //将NSString 转换为char *
    4.     const char *change = [str UTF8String];

    5.     //输出log
    6.     NSLog(@"str = %@ size = %lu", str,sizeof(str));
    7.     NSLog(@"c = %s size = %lu", c, sizeof(c));
    8.     NSLog(@"change = %s size = %lu", change, sizeof(change));

    3 字符串格式化stringWithFormatFormat

       NNString * str=stringWithFormat:@"name is %@:

  • 相关阅读:
    C#中 File,Directory,FileInfo,DirectoryInfo区别与应用
    C#中设置开机自动运行和关机
    C# 线程手册 第三章 使用线程 小心死锁
    C# WinForm判断Win7下是否是管理员身份运行
    C#应用MemoryStream提高File读取速度
    CodeforcesDouble Profiles
    SRM533 D1 L1
    SRM532 D1 L2
    SRM533 D2 L3
    次小生成树 | 割点 | 割边
  • 原文地址:https://www.cnblogs.com/csj007523/p/2561563.html
Copyright © 2020-2023  润新知