char Test

#include <iostream>
#include <vector>
#include <string.h>

using namespace  std;


int main()
{   
    char *p1 = "0123+%";
    char p2 = '0123+%';
    char *p5;
    p5 = &p2;
    //char *p3 = '0123+%'; error
    //char p4[] = '0123+%'; erroer

    cout << p1 <<endl;
    cout << p2 <<endl;//little endin
    //cout << p3 <<endl;
    
    cout << sizeof(p1) <<endl;//sizeof 指针
    cout << strlen(p1) <<endl;//  \0
    cout << sizeof(p2) <<endl;//sizeof 指针
    //cout << strlen(p2) <<endl;//  \0
    cout << strlen(p5) <<endl;
    getchar();
    return 0;
}
View Code

 

posted @ 2021-10-25 21:32  Kiris  阅读(13)  评论(0编辑  收藏  举报