zoukankan      html  css  js  c++  java
  • 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 %@:

  • 相关阅读:
    面向对象的继承关系体现在数据结构上时,如何表示
    codeforces 584C Marina and Vasya
    codeforces 602A Two Bases
    LA 4329 PingPong
    codeforces 584B Kolya and Tanya
    codeforces 584A Olesya and Rodion
    codeforces 583B Robot's Task
    codeforces 583A Asphalting Roads
    codeforces 581C Developing Skills
    codeforces 581A Vasya the Hipster
  • 原文地址:https://www.cnblogs.com/csj007523/p/2561563.html
Copyright © 2011-2022 走看看