J
Jinesh
Dear Guru's:
Have a simple C questions. Is this a bug or am I doing something
reallllly stupid? Here's the code snippet:-
---------------------------Code------------------------------
#include <stdio.h>
void main(void)
{
int i=1;
int array[] = {0, 1, 2, 3, 4};
printf("The element in slot %d is %d\n", i, array);
printf("The element in slot %d is %d\n", (i++), array[(--i)]);
}
----------------------Actual Output---------------------------
The element in slot 1 is 1
The element in slot 0 is 1
---------------------Expected Output--------------------------
The element in slot 1 is 1
The element in slot 1 is 1
--------------------------------------------------------------
Shouldn't the output be all 1's. Why is this happening? Anyone have a
clue?
Operating System: IRIX 6.5.21 (if that helps!!)
Thanks a ton in advance,
-Jin
Have a simple C questions. Is this a bug or am I doing something
reallllly stupid? Here's the code snippet:-
---------------------------Code------------------------------
#include <stdio.h>
void main(void)
{
int i=1;
int array[] = {0, 1, 2, 3, 4};
printf("The element in slot %d is %d\n", i, array);
printf("The element in slot %d is %d\n", (i++), array[(--i)]);
}
----------------------Actual Output---------------------------
The element in slot 1 is 1
The element in slot 0 is 1
---------------------Expected Output--------------------------
The element in slot 1 is 1
The element in slot 1 is 1
--------------------------------------------------------------
Shouldn't the output be all 1's. Why is this happening? Anyone have a
clue?
Operating System: IRIX 6.5.21 (if that helps!!)
Thanks a ton in advance,
-Jin