Ken,I just took a look at the learn C in 21 days link you posted and I'm wondering if this information is available to all? that is, do these people have a large collection of other computer related titles one can read for free? I didn't want to start poking around in case this was some sort of rental tied to an account you established with this organization.
thanks, Matthew---- Original Message ----- From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Saturday, September 22, 2007 7:35 AM Subject: RE: variables in c
The top definition is a Global the one inside the function is a local. When the function is run the local takes over till it exits. If you want a clear definition of scope in C then read this chapter from learning C in 21 hours:http://aelinik.free.fr/c/ch14.htm Ken -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Daniel Dalton Sent: Saturday, September 22, 2007 3:32 AM To: programmingblind@xxxxxxxxxxxxx Subject: variables in c Hi, If I write: #include <stdio.h> int x =6, y =78; void my_function(void); int main () { printf("\nx =%d and y =%d", x, y); my_function (); printf("Left my_function\n"); printf("\nx now =%d and y now =%d", x, y); } void my_function (void) { int x =124, y =245; printf("\nIn my_function\n"); printf("x =%d y =%d\n", x, y); } So are both x and y variables local? The second line of the program(int x, y;) isn't in a function. So how doesthe compiler know what function they are for? Are they global variables? Ifthey are then how can you have a local variable called the same thing as a global variable? Thanks, -- Daniel Dalton http://members.iinet.net.au/~ddalton/ daniel.dalton47@xxxxxxxxx __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ NOD32 2544 (20070921) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind