C的printf()相关参数以及用法。

版权声明:Copyright©2018 Niocho all rights reserved https://blog.csdn.net/weixin_43221330/article/details/82732986

C的printf()相关参数以及用法。

printf()的作用为向控制台输出一段代码,最简单的用法为
printf(char[]);
//例如
printf(“Hello,World!”);


我们可能用他来传递参数
例如:

#include <stdio.h>
    int main(){
    int a = 16;
    float b = 3.1415;
    double c = 22451.222;
    char  d= 'B';
    char[] e = "Hello!";
    //使用%d来打印整型
    printf("Somethinghere %d",a);
    //使用%f来打印浮点
    printf("Somethinghere%f",b);
    //使用%f来打印double
    printf("Somethinghere%f",c);
    //使用%c来打印char
    printf("Somethinghere%c",d);
    //使用%s来打印char[]
    printf("Somethinghere%s",e);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43221330/article/details/82732986