CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Inizialitations variables

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
.C



Joined: 06 May 2004
Posts: 19
Location: Italy

View user's profile Send private message

Inizialitations variables
PostPosted: Sat May 22, 2004 3:14 pm     Reply with quote

Hi
I have notice about "Static" that it is expensive for inizialitations variables.
There is another way , Do you know it ?
.C



Joined: 06 May 2004
Posts: 19
Location: Italy

View user's profile Send private message

PostPosted: Sun May 23, 2004 1:58 am     Reply with quote

...Home keeping
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Sun May 23, 2004 11:17 am     Reply with quote

You can use global variables instead of the keyword "static". The downside to a global variable is that it can be altered outside what should be its scope.

Global variables solve lots of problems but can create many more if you do not use discipline when coding.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
.C



Joined: 06 May 2004
Posts: 19
Location: Italy

View user's profile Send private message

PostPosted: Mon May 24, 2004 2:25 am     Reply with quote

but ,by static the variable is globally active and initialized to 0,What Does the difference?
May be by static the variable are initialized to 0

if I write

int A -> is global
static int b -> is global and initialized to 0

main() {

//

}
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Mon May 24, 2004 7:30 am     Reply with quote

Code:

int8 a=0; // initialized to zero
// could as easily said int8 a=99; to initialize as 99

void main(void)
{
}

_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group