zoukankan      html  css  js  c++  java
  • C- printf的使用

    ASC C之后引入的一个特性是,相邻的字符可以被自动连接

     1 /* printf.cc
     2 * 2014/09/02 update
     3 */
     4 #include <iostream>
     5 using namespace std;
     6 
     7 int main() {
     8     printf("abcd"
     9         "efg
    ");
    10 
    11     char* var[] = {
    12         "adf",
    13         "def" //没有逗号,故自动连接在一起
    14         "ghi",
    15     };
    16 
    17     //sizeof(var)为8
    18     //sizeof(var[0])为4
    19     printf("size of var is: %d
    ", sizeof(var)/sizeof(var[0]));
    20 
    21     for(size_t sz = 0; sz < sizeof(var)/sizeof(var[0]); sz++)
    22         cout << var[sz] << endl;
    23 
    24     int p = 2;
    25     size_t apple = sizeof(int) * p;
    26     printf("apple is: %d
    ", apple);
    27 
    28     int q = 3;
    29     int res = p+++q;
    30     printf("res is: %d
    ", res);    
    31 
    32     struct pig_id {
    33         unsigned int a;
    34     };
    35     return 0;
    36 }
    $ ./a.exe
    abcdefg
    size of var is: 8
    adf
    defghi
    apple is: 8
    res is: 5
  • 相关阅读:
    parallel-fastq-dump是一个大坑
    生信软件安装(2)
    2018年一些感悟
    raw data/PF data/Q30 data/clean data的不同
    专题
    结构体
    指针和数组
    指针
    函数的声明
    C语言中的函数
  • 原文地址:https://www.cnblogs.com/dracohan/p/3915997.html
Copyright © 2011-2022 走看看