yes, because you declared them. c++ checks for functions, classes, and then global scope I believe, c does the same, just eluminate classes. Thanks, Tyler Littlefield. Vertigo head coder "My programs don't have bugs, just randomly added features." msn: compgeek134@xxxxxxxxxxx email: compgeek13@xxxxxxxxx aim: st8amnd2005 skype: st8amnd127----- Original Message ----- From: "Daniel Dalton" <daniel.dalton47@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Saturday, September 22, 2007 4:32 AM 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 does the compiler know what function they are for? Are they global variables? If they 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