当前位置:首页 > 网络编程 > 软件语言 > C语言 > 间接修改指针的地址

间接修改指针的地址

点击次数:20 次 发布日期:2008-12-01 12:51:24 作者:源代码网
源代码网推荐     间接修改指针的地址
    代码:
// test for a pointer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
typedef struct
{
 int *p;
}Test;
int main( )
{
 int *p;
//      p[0] = 4;
// p[1] = 3;
 
 Test test;
 
 p = (int *)&test;
 
 p[0] = 1;
 cout << "p[0] = " << p[0] << endl;
 cout << "test.i = " << test.p << endl;
 return 0;
}

  源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华