zoukankan      html  css  js  c++  java
  • printf和sprintf




    putchar
    getchar

    printf
    scanf

    printf("各位乡亲们,大家好! ");
    printf("%d+%d=%d ", 2, 5, 2 + 5);
    printf("%s,做我女朋友好吗? ", "小敏"); //不管输入的什么,最后都转换成字符显示到了屏幕上.


    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    void main() {
    char l_str1[] = "你好";
    char l_str2[] = "吃饭了吗?";
    char l_str3[100] = { 0 };
    sprintf(l_str3, "%s%s", l_str1, l_str2); //实现字符串相加

    system("pause");

    }



    char l_str1[] = "123456";
    char l_str3[100] = { 0 };
    sprintf(l_str3, "%.4s", l_str1); //取字符串左边




    double l_d=12340000;
    printf("%e",l_d);

    double l_d = 12340000;
    printf("%g", l_d);











    char l_input[100] = { 0 };
    char l_str[100] = { 0 };

    printf("请输入一个颜色:");
    scanf("%s", &l_input);
    sprintf(l_str, "color %s", l_input);
    system(l_str);
    system("pause");

    %p 指针
    %i 有符号十进制
    %d 有符号十进制
    %o 无符号八进制
    %x 无符号十六进制
    %u 无符号十进制
    %c 字符形式输出单个字符
    %s 输出字符串
    %f 以小数点形式输出单、双精度实数
    %e 以标准指数形式输出单、双精度实数.

  • 相关阅读:
    21分钟 MySQL 入门教程
    git学习网址
    Unsupported major.minor version 51.0解决办法
    导入Mybatis_Spring项目遇到的问题
    SQL 模糊查询
    数据持久层
    持久化框架
    ORM
    ORM框架
    重量级框架
  • 原文地址:https://www.cnblogs.com/xiaodaxiaonao/p/7574988.html
Copyright © 2011-2022 走看看