What wrong with this code i see no compilation error. I want to make an array of structures of type pointer to structure. Then i want to assign x and y coordinates and at the end i want to print all the coordinates. I did (*pp).x at places and pp->x at other places. Coz both are one and the same things whats wrong. Please let me know.
#include <stdio.h>
#include <conio.h>
#define MAX_STRUCT 10
struct point{
int x;
int y;
};
void PrintIt(int x, int y);
main()
{
struct point *pp[MAX_STRUCT];
printf("Enter how many coordinates you want to input: ");
int count=0, n;
scanf("%d", &n);
while(count<n){
printf("\nEnter the X & Y coordinate of the point: ");
int i,j;
scanf("%d%d", &i, &j);
(*pp[count]).x=i; /* or we can do this : pp[count] -> x same thing
(*pp[count]).y=j; // or we can do this : pp[count] -> y same thing
count++;
}
PrintIt(pp[count]->x, pp[count]->y);
return 0;
}
void PrintIt(int x, int y)
{
printf("\n(%d,%d)", x, y);
}