zoukankan      html  css  js  c++  java
  • C语言中注意点

    C语言中注意点
    • C把char常量视为int类型,而C++将其视为char类型,

      char ch = 'A';
      int x = 'ABCD';	/* !< 对于int是4字节的系统,该语句出现在C程序中没有问题,但是出现在C++程序中会出错*/
      

    在C中,常量'A' 字符编码储存为一个int类型的值,相同的数值也储存在变量ch中,但是在ch中该值只占内存的1字节

    eg:

    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int x = 'ABCD';
        char c = 'ABCD';
        printf("%d %d %c %c
    ", x, 'ABCD', c, 'ABCD');
        return 0;
    }
    
    /* !< output */
    1094861636 1094861636 D D
    
    Process returned 0 (0x0)   execution time : 0.005 s
    Press any key to continue.
    
    
  • 相关阅读:
    小网络的激活函数
    Dual Path Networks
    RT600之Mailbox
    RT600之OTFAD
    RSA算法详解
    RT600之SB
    RT600之master key
    RT600之PUF
    RT600 Boot详解
    RT如何生成image
  • 原文地址:https://www.cnblogs.com/xzpin/p/12693802.html
Copyright © 2011-2022 走看看