Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Newbie Question on Struct



[EMAIL PROTECTED] (Yang Xiao) writes:

> hi all,
> why doesn't this compile using lcc-win on W2K?
> 
> #include <stdio.h>
> 
> int main(void)
> {
>         typedef struct {int age; char *name;} people;
>         people *person;
>         person->age = 10;
>         person->name="Ricky";
>         return 0;
Well what do you think is *person? It's an unintialized
pointer. Provide the proper amount of memory for it and it will work,
and than use the proper things to copy things person->name= will not
do what you like it to do.

Regards
Friedrich






<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.