delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/26/05:45:33

From: "Kurt Wall" <krwall AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Pointer problems!!
Date: Mon, 26 Jan 1998 03:13:43 -0700
Organization: EarthLink Network, Inc.
Lines: 65
Message-ID: <6ahni4$97b@ecuador.earthlink.net>
References: <199801260544 DOT SAA12728 AT cirrostratus DOT netaccess DOT co DOT nz>
NNTP-Posting-Host: 153.37.49.23
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Posted and emailed.

Richard Chappell wrote in message
<199801260544 DOT SAA12728 AT cirrostratus DOT netaccess DOT co DOT nz>...
>This is a bug report for RHIDE Version 1.4 (Sep 30 1997 23:06:59) I am
>running MS-DOS 6.22
>
[big damn bug report snipped]

>
>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
ERROR: "p" doesn't point at anything, so you're dereferencing garbage
TRY:   p = &b;

>p2=a[0]; // for this one I get a 'incompatible types in assignment'
>       // error
ERROR: "p2" doesn't point at anything, so you're dereferencing garbage
ERROR: "p2" is pointer to mystruct, and you're assigning an integer to it.
       a[0] is the first element in the array; "a" is a constant pointer to
       the base of the array;
TRY:   p2 = a;

WARNING: You realize, of course, that // is not a legal ANSI C comment, but
merely
       an often-supported extension?


>printf("%d %d",p->za,p2->za);

>return(0);
>}

>WHAT IS WRONG WITH IT?
>HOW DO I GET IT TO WORK??

>Please answer !!

And please don't post bug reports like that.  If it _is_ a bug, send the
report to the
maintainer.

Kurt



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019