Soft Ware/C++ 언어!!
포인터를 이용한 재미있는 소스
달려가보자
2012. 1. 27. 21:13
#include <iostream>
using namespace std;
double d =3.14;
typedef struct test Data;
typedef struct test * Pdata;
typedef struct test *(*FP)(Pdata);
typedef int *(*FP2)(Pdata);
struct test
{
int a;
double * d;
struct test *Ptest;
int arrp[3][2];
};
struct test * func1(Pdata Px)
{
return Px->Ptest;
}
int * func2(Pdata Px)
{
return &(Px->a);
}
void my_test(char a,...)
{
cout<<**(double **)(&a+4)<<endl;
cout<<*((*((Pdata *)(&a+8)))->d)<<endl;
cout<<*((*((FP *)(&a+12)))(*((Pdata *)(&a+8)))->d)<<endl;
cout<< **(double **)(((int *)(((*((FP2 *)(&a+16)))(*((Pdata *)(&a+8))))))+1)<<endl;
cout<<**(double **)(((int *)(&a+20))-4)<<endl;
}
int main()
{
Data x = {100,&d,&x,{0,100,200,300,400,500}};
my_test('A',&d,&x,func1,func2,&x.arrp[0][2]);
}