【C\C++笔记】数组指针越界

指针越界,t的数组指针越界,修改了c的内容。

使用指针时,必须规定指针移动的范围

#include <iostream>

using namespace std;

int main(){

char c[11]="123456";

char t[11];

for(int i = 0;i<20;i++){

t[i]='a'+i;

}

cout<<c<<endl;

return 0;

}

输出:
PS E:\桌面> cd "e:\桌面\" ; if ($?) { g++ test.cpp -o test } ; if ($?) { .\test } lmnopqrst