419 posts
Location
your hardrive
Posted 16 July 2012 - 09:11 PM
iv seen most people global using local variables in there programs and i want to know why should use them
1604 posts
Posted 16 July 2012 - 09:35 PM
Well, it's bad practice to use global variables. Any program can access them, so it brings security isues. If the only program running is yours, then it should be ok. But you can't ensure that (there could be some program running on the background), and one could mess up the other (you expected a variable to be of some type, but it changed in the other program and now your program crashes).
Also, global variables stay when the program ends, so you shouldn't store anything like passwords, etc. cause other program could read them.
419 posts
Location
your hardrive
Posted 16 July 2012 - 09:50 PM
thanks :P/>/>