非法的內存訪問
發布時間: 2022-07-04 07:20:57
1. 關於C++非法訪問內存
兩個錯誤,一是全局變數str沒有空間;二是,你看下自己的函數,str在自加,執行完函數後,str指向最末尾,然後你就直接cout<<str<<endl。。。。
#include<iostream>
usingnamespacestd;
#defineN50
char*cat(constchar*str1,charconst*str2)
{
char*str=newchar[N];
char*p=str;
while(*str1!='