0 ‘与‘’、 ‘0’

#include "stdafx.h"
#include "string.h"
#include "iostream"

int _tmain(int argc, _TCHAR* argv[])
{
    char x[]="STRING";//系统认为是char x[7];
    char y[]="00ING";//写在字符串中的是‘0’   0当成八进制处理为对应的ASCII码对应的字符 所以系统认为是char y[6];        这两个字符串系统都加了‘’
    x[0]=0;x[1]='';x[2]='0';x[0]是整数零 ,相当于ASCII码 所以对应为‘’
    printf("%d %d
",sizeof(x),strlen(x));
    printf("%d %d
",sizeof(y),strlen(y));

    system("pause");
    return 0;
}

所以结果为:

7 0

6 1

原文地址:https://www.cnblogs.com/kinghyt/p/10190884.html