C Programming - Pointers - Discussion

Discussion Forum : Pointers - True / False Questions (Q.No. 2)
2.
Will the program compile?
#include<stdio.h>
int main()
{
    char str[5] = "IndiaBIX";
    return 0;
}
True
False
Answer: Option
Explanation:

C doesn't do array bounds checking at compile time, hence this compiles.

But, the modern compilers like Turbo C++ detects this as 'Error: Too many initializers'.

GCC would give you a warning.

Discussion:
4 comments Page 1 of 1.

Praveen said:   7 years ago
Explain me clearly.

BHANU said:   1 decade ago
Actually string allocates a space of 5 character but tha string we are assigning is too long but then also it accepts.

Cherry said:   1 decade ago
Can you explain with an example for array bounds checking at compile time.

Abhishek said:   1 decade ago
Can anyone explain me the solution of above problem? As soon as possible

Post your comments here:

Your comments will be displayed after verification.