Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
An Exercise Using Pointers in C
Given the following Point Struct Create 5 points and chain them together using the next pointer, then print them out using a while loop.
Struct Position { int x; int y; point *next;
}
int main ( int argc, char **, argv) {
position a; a.x = 100; a.y = 200;
position a2; a2.x = 1000; a2.y = 2000; a2.next = NULL; a.next = &a2;
position a3; a3.x = 10000; a3.y = 20000; a3.next = NULL; a2.next = &a3;
position a4; a4.x = 100000; a4.y = 200000; a4.next = NULL; a3.next = &a4;
position a5; a5.x = 1000000; a5.y = 2000000; a5.next = NULL; a4.next = &a5;
position aa = &a;
while (aa != NULL) {
printf("%d,%d\n", aa->x, aa->y); aa = aa->next;
}
}
That is my solution…:D