zoukankan      html  css  js  c++  java
  • [C]字符串读取,遇0结束

    #include <stdio.h>
    int main()
    {
        char a[] = "The quick brown fox jumps over the lazy dog.";
        a[4] = ''; //a[] = "The uick brown fox jumps over the lazy dog."
        //或者a[4] = 0;
        printf("%s#
    ", a); //字符串读到0,即结束
        return 0;
    }
    
    //所以结果为:The #
    #include <stdio.h>
    int main()
    {
        // char a[] = "The quick brown fox jumps over the lazy dog.";
        // a[4] = ''; //a[] = "The uick brown fox jumps over the lazy dog."
        //或者a[4] = 0;
        char a[] = {'q', 'u', 'i', 'c', 'k', 'b', 'r', 'o', 'w', 'n'};
        printf("%s#
    ", a); //字符数组: 如果没有0,读到结尾, 输出:quickbrown#
        a[4] = 0; //'k'换成0;
        printf("%s#
    ", a); //字符串遇到0,就结束.输出:quic#
        return 0;
    }
    //思考题:输出结果为何?
    #include <stdio.h>
    int main()
    {
        char a[] = "The uick brown fox jumps over the lazy dog.";
        printf("%s#
    ", a);
        return 0;
    }
  • 相关阅读:
    公司真题-字节跳动
    全素组探求
    枚举
    求n个整数的最大公约数
    Ajax技术
    读文本文件
    JSTL标签库
    URL跟URi的区别
    常用的JSTL标签
    EL表达语言
  • 原文地址:https://www.cnblogs.com/profesor/p/12963857.html
Copyright © 2011-2022 走看看