調試時我發現我的程序停在:「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;
}
}
'空隙myfun();'不調用一個函數。這是一個函數聲明。 – 2015-02-11 05:06:59