Sample 4.19:addpntrs.cpp
2013-12-02 22:08
531 查看
#include<iostream> int main() { using namespace std; double wage[3] = {10000.0, 20000.0, 30000.0}; short stacks[3] = {3, 2, 1}; double * pw = wages; short * ps = &stacks[0]; cout << "pw = " << pw << ", *pw = " << *pw << endl; pw = pw + 1; cout << "add 1 to the pw pointer:\n"; cout << "pw = " << pw << ", *pw = " << *pw << "\n\n"; cout << "ps = " << ps << ", *ps = " << *ps << endl; ps = ps + 1; cout << "add 1 ot the ps pointer:\n"; cout << "ps = " << ps << ", *ps = " << *ps << "\n\n"; cout << "access two elements with array notation\n"; cout << "stacks[0] = " << stacks[0] << ", stacks[1] = " << stacks[1] << endl; cout << "access two elements with pointer notation\n"; cout << "*stacks = " << *stacks << ", (stacks + 1) = " << *(stacks + 1) << endl; cout << sizeof(wages) << " = size of wages array\n"; cout << sizeod(pw) <, " = size of pw pointer\n"; return 0; }
相关文章推荐
- Sample 4.18:arraynew.cpp
- Sample 4.17:use_new.cpp
- Sample 4.16:init_ptr.cpp
- Sample 4.15:pointer.cpp
- Sample 4.14:address.cpp
- Sample 4.13:arrstruct.cpp
- C语言动态存储分配
- Sample 4.12:assgn_st.cpp
- Sample 4.11:structur.cpp
- Sample 4.9:strtype3.cpp
- Sample 4.8:strtype2.cpp
- Sample 4.7:strtype1.cpp
- Sample 4.6:numstr.cpp
- Sample 4.5:instr3.cpp
- Sample 4.4:instr2.cpp
- Sample 4.3:instr1.cpp
- Sample 4.2:string.cpp
- Keil C51对C语言的关键词扩展之十七: sbit
- c++写的一个简单的管理系统
- memcpy和memmove的区别