delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/20/14:31:16

From: "Chia" <chia AT top DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re-Mallocing an array...
Date: Wed, 20 May 1998 13:20:29 -0500
Organization: 404 Software
Lines: 19
Message-ID: <6jv6s8$kn1@nnrp4.farm.idt.net>
NNTP-Posting-Host: pm1-8.top.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Say I have...

int *foo;

I do this:

  foo = (int *)malloc( sizeof(int) * 10);

And then I want to change it to hold 20 ints.  So, I figured I'd free it and
then remalloc it.

  free(foo);
  foo = (int *)malloc( sizeof(int) * 20);

but this crashes.  How do I do this, then?

Thanks!


- Raw text -


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