delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/23/10:45:22

From: Jukka Mickelsson <jukka AT mbnet DOT fi>
Newsgroups: comp.os.msdos.djgpp
Subject: How to use malloc?
Date: Fri, 23 Jan 1998 15:45:03 +0200
Organization: DLC Data Link Connections
Lines: 23
Message-ID: <34C89EDF.ACBAE798@no-spam.mbnet.fi>
NNTP-Posting-Host: 195.218.68.124
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a problem using the malloc() function since I don't really know
what to do with it.
I have the following type program:

struct menuitem() {              // this source code is simplified
  char *description[25];
}

struct menuitem menu[5];

for(i=0; i<5; i++)
for(e=0; e<X; e++)
menu[i].description[e] = "testing";

The problem is that when X > 3 the program starts to act in a weird way
or crashes
sometimes. I probably should use malloc() here but I haven't got a
slightest idea _where_
and _how_.
Could anyone help?



- Raw text -


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