test c++

test c++

 

#include <iostream>
using namespace std;

int main()
{
    char myChar[6] = { 'H', 'e', 'l', 'l', 'o', '\0' };
    //char* pointer = myChar;        //WORKS!!!
    char* pointer = &myChar[0];        //ALSO WORKS!!!

    cout << myChar << endl;        //Hello
    cout << &myChar << endl;    //00000030DDEFF744  Array start
    cout << myChar[0] << endl;    //H
    cout << myChar[1] << endl;    //e
    cout << &myChar[0] << endl;    //Hello

    cout << pointer << endl;        //Hell0
    cout << *pointer << endl;        //H
    cout << *(pointer + 1) << endl;    //e
    cout << *(pointer + 2) << endl;    //l
    cout << (const int*)pointer << endl;    //00000030DDEFF744   =  &myChar 
    cout << &pointer << endl;            //00000030DDEFF768    ptr itself

    return 0;
}

 

 

 

##################################

posted @ 2024-04-02 15:08  西北逍遥  阅读(5)  评论(0编辑  收藏  举报