#include <stdio.h>
#include <stdlib.h>
str1
{
int k;
struct str1 * ptr1;
};
int main(void)
{
int * p1, * p2;
struct str1 * ptr2;
ptr2 = (struct str1 *) malloc(sizeof(struct str1));
ptr2 -> ptr1 = (struct str1 *) malloc(sizeof(struct str1));
ptr2 -> ptr1 -> ptr1 = ptr2;
ptr2 -> k = 7;
ptr2 -> ptr1 -> k = 25;
p1 = (int *) ptr2 -> ptr1;
p2 = (int *) ptr2 -> ptr1 -> ptr1;
printf("%d %d\n", * p1, * p2);
ptr2 -> ptr1 -> ptr1 -> k ++;
printf("%d %d\n", * p1, * p2);
ptr2 -> ptr1 -> ptr1 = ptr2 -> ptr1;
ptr2 -> ptr1 -> ptr1 -> k = 44;
printf("%d %d\n", * p1, * p2);
* p1 = * p2 = 65;
if( ptr2 = = ptr2 -> ptr1 ) printf("Equal\n");
else printf("Not equal\n");
return 0;
}
In this code, I did not understand what this ptr2 -> ptr1 -> ptr1 = ptr2;
code works. Is it attaching a structure another structure and ptr2 -> ptr1 -> ptr1 = ptr2;
What ths code pointing at. Sorry for my bad english. Thank you for your answers.