Advertisement

variable declaration

Started by February 09, 2003 05:21 PM
3 comments, last by viper35al 21 years, 9 months ago
what does it mean when a program says int choice, i;? Thanks. [edited by - viper35al on February 9, 2003 6:22:53 PM]
It means that you are declaring two variables (''choice'' and ''i'') of type ''int''. It is a short-hand way of writing:

int choice;
int i;
Advertisement
It is declaring two integer variables, with names choice and i.

Be careful with this syntax if you want to declare multiple pointers in one line i.e.

int * choice, i;

does not declare two pointers, but one called choice, the other an integer, i, however:

int * choice, * i;

does declare two integer pointers.
int choice, i;
is a declaration of two integers, choice and i. It''s a short-cut of saying:
int choice;
int i;

wow, I cannot believe that I forgot what that meant. I learned that a long time ago.

sorry for asking such a stupid question

thanks for the responses though.

This topic is closed to new replies.

Advertisement