TIP: Click on subject to list as thread! ANSI
echo: nthelp
to: John Beckett
from: Geo
date: 2004-11-22 22:20:22
subject: Re: C++ for beginners?

From: "Geo" 

I'm unclear, how is loglines2 related to loglines in the below or were you
just giving me two examples in the same program?

Geo.

"John Beckett"  wrote in
message news:8o85q0d05jjpmsga0lvsnp5b0j5fo9mh9h{at}4ax.com...
> On Mon, 22 Nov 2004 18:44:47 -0500, "Geo"
 wrote:
> > char loglines{4096][256]
> You probably need to master the basics before contemplating Paul's
> more correct comments. The basics are:
>
> 1. A function variable ("auto") occupies stack memory.
> 2. Global variables (defined outside functions) occupy data memory.
> 3. The qualifier "static" has two meanings:
>      - On a function variable, it means use data memory, not stack.
>      - On a global variable, it means "visible here only".
>
> The above is a rather crude summary. Anyway, you could solve your
> problem by putting "static" in front of the array variable.
>
> Alternatively, you could move the variable outside a function (in that
> case, the "static" would not be required, but would be good practice
> to indicate that you only intend the variable to be used from within
> the current source module).
>
> // Crude example.
> #include 
>
> const int MAXLINES = 4096;
> const int MAXLEN = 255;
> static char loglines2[MAXLINES][MAXLEN+1];
>
> void main()
> {
>     static char loglines[MAXLINES][MAXLEN+1];
>     for ( int j = 0; j < MAXLINES; ++j )
> sprintf(loglines[j], "%d Sample Log Text", j);
> }
>
> The above has TWO arrays (loglines2 is not used).
>
> John
>

--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)
SEEN-BY: 633/267 270 5030/786
@PATH: 379/45 1 396/45 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.