| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | variable initialization |
> According to "C, A Reference Manual," if the variable is static or > external, then the initializer must be constant. However, for > automatic variables any expression can be used. (p.85) Therefore > your example is perfectly legal. It is, yes (Paul's original post never got here for some reason :-(). > Kind of makes sense too, since global/static variables are > initialized only once before main executes. While automatic > variables gets initialized each time through the function, so > any expression simply becomes the first statement the function > executes. In C++, non-constant expressions and function calls can also be used as initialisers even for static/global variables. I thought it worth mentioning as being one difference between std C and C++. cheers, david ---* Origin: Unique Computing Pty Ltd (3:632/348) SEEN-BY: 50/99 54/54 620/243 623/630 632/103 301 348 386 998 633/371 634/384 SEEN-BY: 635/210 502 503 544 636/100 670/206 711/409 430 807 808 809 932 934 SEEN-BY: 712/623 713/888 714/906 800/1 @PATH: 632/348 635/503 50/99 54/54 711/808 809 934 |
|
| 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™.