One man told me that the following construction is legal for c:
int [10] a;
because square brackets is the kind of the komment symbol in the ansi c
standard, but VC++5.0 gives a compile error.
So, the question is, does the man wrong, or i did something wrong ?
> One man told me that the following construction is legal for c:
> int [10] a;
> because square brackets is the kind of the komment symbol in the ansi
He's wrong. Brackets are definitely not comments, but an important
syntactic element of both C and C++.
Comments are delimited by surrounding them with /* or */.
Also in C++, anything from // to the end of a line is a comment.
[] is used for pointer dereferencing and array declarations.
Your line is illegal.
int /* 10 */ a; // Make an int called a, with a comment in the middle.
int a[10]; // make an array called a of 10 ints.
>Hi !
>One man told me that the following construction is legal for c:
>int [10] a;
>because square brackets is the kind of the komment symbol in the ansi c
>standard, but VC++5.0 gives a compile error.
>So, the question is, does the man wrong, or i did something wrong ?
Did he give you that information on April 1st? Not only are square
brackets _not_ a comment symbol in C, but I fail to remember _any_
language that uses square brackets as a comment symbol.
int [10] a;
cannot be derived from anything in the C syntax that I am aware of.
The current definition of C knows just one kind of comments, and
that is
/* This is a comment */
Single line comments will be a feature of C9X, but I doublt that square
brackets will be used to denote comments in any future version of C.
Just imagine a language definition that states: An expression in
square brackets is a comment if it cannot be interpreted as anything else
in the current context.
Kurt
--
| Kurt Watzka Phone : +49-89-2178-2781
| wat...@stat.uni-muenchen.de
// comments out text to the end of the line
/* everything inside this is a comment */
The man was pulling your chain, dude.
Alexey Maykov wrote in message <34915...@news.telekom.ru>...
May be you are right, but I sow in coding standards of my
organization another proof of my suugestion. There is a recomendation for
commenting source code:
/******************************
* Function that inputs and sorts an array
* [1] declare array
* [2] input array
* [3] sort array
*******************************/
int a[SIZE]; [1]
//.....
for( int i=0; i < SIZE; i++ ) [2]
//....
for( int i=0; i < SIZE; i++ ) [3]
As you can see here its a comment technique where you first put a plan of
the futeure work and then use references for that plan. For this references
you can use brackets. But this example do not compile by VC 5.0.
Alex Maykov, IMSI
> int a[SIZE]; [1]
> //.....
> for( int i=0; i < SIZE; i++ ) [2]
> //....
> for( int i=0; i < SIZE; i++ ) [3]
> As you can see here its a comment technique where you first put a plan of
> the futeure work and then use references for that plan. For this references
> you can use brackets. But this example do not compile by VC 5.0.
>
Nope. That won't compile under any environment I've seen. That is a
typographic convention from a book, not C/C++ source code.
In order to accomplist what you want, use the "//" symbol:
int a[SIZE]; // [1]
//.....
for( int i=0; i < SIZE; i++ ) // [2]
//....
for( int i=0; i < SIZE; i++ ) // [3]
--
Charles Krug, Jr.