Identifier Names can be Confusing
Names given to identifiers are often confusing to beginners in C/C++ programming. But sometimes even expert programmers will have their share of trouble with some of the valid identifier usage in C/C++. For example consider the code given below. It is a perfectly valid C code.
// int ok; // This Statement will give you an Error.
printf("Value of ok.ok is %d\n",ok.ok);
Download the C Program.
Download the C++ Program.
The same identifier name ok is used as the structure name, a structure member, structure variable and a label for goto statement. Such a repeated use of same identifier is allowed in C/C++ until conflicts occur. If you add the statement int ok; to the program there arises a conflict and thus you will get an error. Otherwise there is no error.
The Output is Shown Below