请大家帮我解释以下 问题

img


/ 48.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
using namespace std;
int main()
{
    char str[10];
    char* strip = str;
    //输入输出
    cout << "str=";
    cin >> str;//用字符数组输入字符串
    cout << "str=" << str << endl;
    cout << "strip=" << strip << endl;
    cout << "strip=";
    cin >> strip;//用字符指针变量输入字符串
    cout << "str=" << str << endl;
    cout << "strip=" << strip << endl;
    //利用指针变量改变其指向字符串的内容
    *(strip + 2) = 'l';
    cout << "str=" << str << endl;
    cout << "strip=" << strip << endl;
    //动态为字符型指针变量分配内存
    strip = new char(100);
    cout << "strip=";
    cin >> strip;//用字符指针变量输入字符串
    cout << "str=" << str << endl;
    cout << "strip=" << strip << endl;


}

1-为什么指针变量strip能通过cin赋值
2-为什么cout输出的strip而不是*strip输出的是str的值而不是地址
3- strip = new char(100);是什么意思
4-str[10]不是只有10个位置一个汉字占两个字符串结尾还有\n,而且我输入的“程序执行将在此处开始并结束”有13个汉字他为什么能正常输出

1.cin输入时,是对一块地址进行写值,而指针strip刚好是一个地址。
3.申请100个char类型的空间
4.数组越界后的地址空间是合法的就可以输出,越界太多会往非法地址写值,会导致程序运行出错

strip = new char[100];
你写的 strip = new char(100)只是创建一个字节的指针,初始值是100