Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!rpi!masscomp!peora!tarpit!tous!alfred!fang!ablnc!abcom!ncsc1!dcl From: dcl@ncsc1.ATT.COM (Dave Love) Newsgroups: comp.sys.amiga Subject: Re: Large string variables in C. Message-ID: <720@ncsc1.ATT.COM> Date: 4 Jan 91 20:37:31 GMT References: <40546@nigel.ee.udel.edu> Followup-To: comp.lang.c Organization: National Customer Support Center Lines: 53 In article <40546@nigel.ee.udel.edu> DA3721A@acad.drake.edu writes: >Hello C programmers, > I am currently working on a C program that requires the usage of >several very large strings (~10 strings of 1000+ characters each). Do I need >to use AllocMem or some other memory routine to allocate memory for these >strings or am I safe if I do not? This is probably a better question for comp.lang.c, so I've redirected the followups there. Basically, you have three options: 1. Declare the strings statically (outside of any funtions, or by using the 'static' keyword): char string[10][1000]; void main() {...}; 2. Declare the strings within a function ('auto'): void main() { char string[10][1000]; ... } Note: on the Amiga you will need to set a large stack size in order for this to run (say STACK 30000). Otherwise you WILL crash the system. 3. Declare the strings dynamically: void main() { int i; char *string[10]; for (i = 0; i < 10; i++) string[i] = malloc(1000); /* or, for the Amiga: string[i] = AllocMem(1000,0); */ ... } > > David Aschbrenner > DA3721A@drake.bitnet -- Dave Love UUCP: dcl@ncsc1.att.com CI$: 75126,2223 bix: dlove -- "MS-DOS... The ultimate PC virus." --