Mail Archives: djgpp/1998/01/26/06:45:36
Richard Chappell wrote:
> My problem is the following:
> ============================
> this is my sample program...
>
> #include <stdio.h>
>
> typedef struct
> {
> int za;
> } mystruct;
>
> int main()
> {
> mystruct a[2];
> mystruct b;
> mystruct *p,*p2;
>
> a[0].za=98;
> a[1].za=99;
> b.za=5;
> *p=b; // for this one I get a SIGSEGV error
p is an uninitialized automatic veriable so it can contain any value,
therefore *p could be anywhere in memory
> p2=a[0]; // for this one I get a 'incompatible types in assignment'
> // error
p2 is a pointer
a[0] is a mystruct
>
> printf("%d %d",p->za,p2->za);
>
> return(0);
> }
As Nate keeps pointing out in posts to other people, basic c/c++
questions belong in one of the c or c++ ng's. (Of course, Nate's been
posting to this ng a lot longer than I have, so he can get away with
saying that :).
--
Ned Ulbricht
mailto:nedu AT ee DOT washington DOT edu
- Raw text -