Char

#include <string>
#include <iostream>
using namespace std;

void fun(char str[100]);

void main()
{
    char c[] = {'a','b','c','d','e','\0'};
    char c1[] = {'a','b','c','d','e'};
    char c2[]="ab\0cd\n";
    string s = "ab\0cd\n";
    cout << c << "  " << sizeof(c) << endl;                   //abcde  6
    cout << c1 << "  " << sizeof(c1) << endl;               //abcde烫烫烫烫烫蘟bcde  5
    cout << c2 << "  " << sizeof(c2) << endl;               //ab  7
    cout << s << "  " << sizeof(s) << endl;                   //ab  32

    unsigned char * quan1 =  (unsigned char *) malloc(1000* sizeof(unsigned char));
    unsigned char * quan = NULL;
    quan = new unsigned char[10];
    quan[0] = '16\0';
    quan[1] = 16;
    printf("%d\n",quan[0]);                               //0
    printf("%d\n",quan[1]);                               //16
    cout << quan[0] << "  " << quan[1] << endl;
    cout << sizeof(quan[0]) << "  " << sizeof(quan[1]) << endl;            //1  1
    cout << sizeof(char) << "  " << sizeof(unsigned char) << endl;       //1  1
    cout << sizeof(int) << "  " << sizeof(long) <<endl;                           //4  4
    delete quan;

    char str[100];
    fun(str);

    system("pause");
}


void fun(char str[100])
{
    cout << "2014.03.24" << endl;
    char name[] = "C++ Game";
    char name1[100] = "C++ Game";
    cout << sizeof(str) << endl;                //4
    cout << sizeof(name) << endl;           //9
    cout << strlen(name) << endl;           //8
    cout << sizeof(name1) << endl;         //100
    cout << sizeof(char *) << endl;           //4
    cout << sizeof(char &) << endl;          //1
    cout << sizeof(short &) << endl;         //2
}

Center

 

转载于:https://my.oschina.net/ucliaohh/blog/806162

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值