Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Table with negative index.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="klays, post: 3525019"] Hi all, I have created char array, when I use tab[-10] compiler shouts out: error: size of array 'tab' is negative I tried to cheat compiler and a little modify this code. Look at the code: void check(int lenght, int index) { char tab[lenght]; tab[index] = 'a'; printf("Character: %c, Sizeof: %d", tab[index], sizeof(tab)); } Call: check(-10, -2); Output: Character: a, Sizeof: -10 My questions are: answer = Is it correct initializing array? if (YES == answer) { Why do compiler allow to this instruction? } else { Why not ? } Please, explain me it. Thanks in advance Klays [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Table with negative index.
Top