Why doesn't the compiler warns me about an obvious error?

后端 未结 5 1477
清歌不尽
清歌不尽 2020-12-12 07:48

So, I just studied the Arrays material and got a problem...
I got this following code:

int a[5]; 
int i;
for(i=0; i<=10; i++) {
             


        
5条回答
  •  独厮守ぢ
    2020-12-12 08:35

    This error has nothing to do with the compiler. Whether it's C or Java, as long as it does not violate the language syntax and semantic, the code will compile.

    What you have is a logical error which could be detected by the language run-time environment, e.g. JVM, which what C lacks.

提交回复
热议问题