调试时我发现我的程序停在:"cout <<*ptr; cout <<"\n";" 这段代码有什么问题?
#include<iostream>
using namespace std;
int *ptr = 0;
void myfun(void);
int main()
{
void myfun();
for(int j = 1; j < 3; j++)
{
ptr = ptr-j ;
cout << *ptr ; cout << "\n";
}
return(0);
}
void myfun(void)
{
int x[3] = {11,12,13};
for(int i = 0; i <3; i++)
{
ptr = &x[i];
ptr = ptr+1;
}
}
Run Code Online (Sandbox Code Playgroud)