delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/27/07:20:43

From: snowball3 AT bigfoot DOT com (Mark E.)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP specific strcpy() error
Date: Sat, 26 Jun 1999 22:41:45 GMT
Organization: Snowball's Web
Message-ID: <3775562b.3658328@news3.ibm.net>
References: <7l3h51$7vv$1 AT nnrp1 DOT deja DOT com>
X-Newsreader: Forte Agent 1.5/32.452
MIME-Version: 1.0
NNTP-Posting-Host: 129.37.91.233
X-Trace: 26 Jun 1999 22:41:29 GMT, 129.37.91.233
Lines: 23
X-Notice: Items posted that violate the IBM.NET Acceptable Use Policy
X-Notice: should be reported to postmaster AT ibm DOT net
X-Complaints-To: postmaster AT ibm DOT net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I1269U <i1269u AT my-deja DOT com> wrote:

>main() {
>    RECORD *testing;
>
>    /* Structured this way for readability */
>    /* Simulated input from user */
>    char ssn[10] = "123456789";

>    strcpy(testing->ssn, ssn);

At least in your sample code, 'testing' is pointing to unallocated mrmory. 

Try adding:
testing = malloc(sizeof(RECORD))

and at the end of your sample code:
free(testing)


-- 
Mark E.: snowball3 AT bigfoot DOT com
http://snowball.frogspace.net/

- Raw text -


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