This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

What do you think of these coding strategies?


I have some philosophical questions for the Wise Ones of C programming.


To limit the scope of index variables, I saw this the other day but it might be C++ or something (perhaps even c#)

for(int x=1; x < 10; x++) {
	/* x is good here */
	printf("%d \n",x);
}

/* x no longer good */


How about:


if (x == 3) {
	int j;    /* explain local j*/
	int k;    /* explain local k*/

    j = 3;
 	k = something;

}

To "hide j and k, only used inside the if statement, and to define them nearer to
where they are used.


------------

I have been told that global variables are bad... I am writing my own star-trek program and
I use two big arrays to hold the Quadrant and Sector grids, I make these global variables
so I don't have to pass them around. Bad?


-------------

When I finish my Star-Trek game, is there a place I can post it for critique?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]