www.delorie.com/archives/browse.cgi | search |
Message-ID: | <3698D534.42E4949E@montana.com> |
Date: | Sun, 10 Jan 1999 09:28:36 -0700 |
From: | bowman <bowman AT montana DOT com> |
X-Mailer: | Mozilla 4.5 [en] (Win95; I) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
Subject: | Re: reusing string variables |
References: | <3697AD5C DOT C9493E2E AT iocc DOT com> <778dup$65j$1 AT news DOT luth DOT se> <3697BB38 DOT 87B2F2D1 AT iocc DOT com> <778lf3$90j$1 AT news DOT luth DOT se> <3698A560 DOT E2215062 AT iocc DOT com> |
Reply-To: | djgpp AT delorie DOT com |
vern wrote: > > void msginput(char *msg) /* NEEDS WORK */ > > char msg1[78]; /* always contains line 1 */ The scope of msg1 to msg4 is limited to msginput(char*). Once the function returns, the storage (on the stack) is destroyed, and with it your data. It looks like you are trying to store prior messages in those arrays, but everytime you return to the function, everything will be garbage but char* msg. Either make msg1 - 4 global, or put them someplace where they will persist throughout their use.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |