Bill Cunningham said:
Ok I see my first choice was correct. My gut choice as this page from a
short tutorial shows. I should've used %s and %d instead of %p. Why is this
below not a constraint violation?
By "this below" do you mean the following paragraph or the code?
Pointers to structures
When you use a pointer to a structure you must use -> instead of a dot.
Right. The "." operator requires an expression of struct type as its
left operand. The "->" operator requires an expression of
pointer-to-struct type as its left operand. In either case, providing
anything else violates a constraint, which means that the compiler is
required to produce a diagnostic. (For "struct", read "struct or
union".)
(Note that if you're using gcc, some constraint violations result in
warnings, not error messages. Both are diagnostics, and neither
should be ignored.)
On to the code you posted. Did you compile it? If so, why aren't you
showing us the diagnostic messages?
#include<stdio.h>
typedef struct person
{
char *name;
int age;
} PERSON;
int main()
{
PERSON p;
PERSON *pptr;
PERSON pptr = &p;
You've declared pptr twice with different types. Your compiler
complained about it, and you foolishly ignored its complaints.
This error could cause the compiler to become confused and produce
incorrect diagnostics for the rest of the code.
I won't waste my time analyzing the rest of your code. Either fix
it so it doesn't produce any diagnostics, or post the code with
the diagnostics and ask us for help in fixing them.
When fixing code to remove diagnostics, it's usually best to start
with the first reported problem. Diagnostics after the first can
be unreliable.