ITeye博客

指针问题

Rejoy · 2009-05-14 11:35 · Markdown

1 #include 2 using namespace std; 3 4 int main () 5 { 6 char c = "hell"; 7 int i = {1,2,3,4,5}; 8 char a = 'o'; 9 10 char(p1) = &c; 11 char p2 = c; 12 int(p3) = &i; 13 int p4 =i; 14 char* p5 = &a; 15 16 cout << "p1=" << *p1 << endl; 17 cout << "p2=" << *p2 << endl; 18 cout << "p3=" << *p3 << endl; 19 cout << "p4=" << *p4 << endl; 20 cout << "p5=" << *p5 << endl; 21 return 0; 22 }
输出结果为: p1=hell p2=h p3=0xbfa401b0 p4=1 p5=o

p1=&c => *p1就是c p2=c => *p2就是c p3=&i => *p3就是i p4=i => *p4就是i p5=&a => *p5就是a

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。