|
-
February 20th, 2005, 09:30 AM
#1
Pointer Question? (Small fun about pointer :D)
Sometimes I am crazy about pointers in C/C++, but I love it.
Today I post this small fun about pointers 
Could you say what is printed on the consol window after the program finishs and explain why? How many bytes of memory are not free?
Code:
#include <stdio.h>
#include <memory.h>
void SetText(void***** p, char v){memcpy(****p,&*&v,1);}
void UcaseOrLcase(char& v, char u){v-=32;u-=32;}
int main(int argc, char* argv[])
{
char cs[5][3]={'h','l','e','l','o','m','m','r','r','r','s','e','o','y',' '};
char (*c2)[3] = &cs[2];
char (*c3)[3] = cs + 3;
char outtext[15]={0};
char *****tmp;
tmp=new char**** [1];
*tmp=new char*** [1];
**tmp=new char** [1];
***tmp=new char* [2];
****tmp=new char[6];
memcpy(tmp+(c3-c2),*c2,1);
memcpy(*tmp+1,&cs[0][2],1);
memcpy(**tmp+1,*(cs+3),1);
memcpy(***tmp+2,0[c3],1);
SetText((void*****)tmp,cs[4][1]);
outtext[0]=(char)*(tmp+1);
outtext[1]=(char)*(*tmp+1);
outtext[2]=(char)*(**tmp+1);
outtext[3]=(char)*(***tmp+2);
outtext[4]=(char)*(****tmp);
outtext[5]=*(*(cs+(int)c3-(int)c2+1)+2);
outtext[6]=0;
UcaseOrLcase(*outtext,outtext[5]);
char *****tmp2=new char**** [20];
*tmp2=(char****)(tmp2+1);
*(tmp2+1)=(char****)(tmp2+2);
*(tmp2+2)=(char****)(tmp2+3);
*(tmp2+3)=(char****)(tmp2+4);
4[tmp2]=(char****)&*&5[tmp2];
memcpy(****tmp2,"world\n\0",6);
memcpy((tmp2+4),"christmas\n\0",11);
UcaseOrLcase(0[****tmp2],(char)*(tmp2+4));
printf("%s%s",outtext,(char*)*&*&*&*&*&****tmp2);
return 0;
}
Have fun
(Tested in VC++ 6.0)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|