#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct name
{
int a;
char b[10];
char c;
};
int main()
{
struct name *p;
p = (struct name *)malloc(3 * sizeof(struct name));
char *n;
n = "12345";
n = (char *)p;
n = (int*)n; /*this is not correct . in doubt....change correctly*/
strcpy(n+(sizeof(p->a)),"ALL");
*(n+sizeof(p->a)+sizeof(p->b)) = 'D';
*(n+(sizeof(p[0]))) =245678; /*change this line also*/
strcpy((n+sizeof(p->a)+sizeof(p[0])),"IS");
*(n+sizeof(p[0])+sizeof(p->a)+sizeof(p->b)) = 'B';
*(n+(sizeof(p[0])+sizeof(p[0]))) =233456; /*change this also*/
strcpy((n+(2*sizeof(p[0])+sizeof(p->a))),"WELL");
*(n+(2*sizeof(p[0])+sizeof(p->a)+sizeof(p->b))) = 'C';
printf("n1 = %s %s %c\n",p[0].a,p[0].b,p[0].c);
printf("n2 = %d %s %c\n",p[1].a,p[1].b,p[1].c);
printf("n3 = %d %s %c\n",p[2].a,p[2].b,p[2].c);
}
This is my program..........anyway this is like complex.........its my assignment......almost i finish this program.......what my problem is when i give *n=12345; this line gives output as 45(i.e)by converting into hexadecimal........what i want is watever we give in *n it should print as it is........so we have to TYPECAST on 17th line so how to typecast this and print the same output as in input...........there is a way but i dont know................