S
somenath
I am not able to understand why the following program output as follows.
#include<stdio.h>
void test(int x,int y)
{
printf("x = %d\n",x);
printf("y = %d\n",y);
}
int main(void)
{
int i =5;
int j =5;
test(++i,j++);
return 0;
}
$ ./a.exe
x = 6
y = 5
According to my understanding function call provide sequence point i.e all the side effect will be guaranteed to be complete ( after the evaluation of all the arguments, and just before the actual cal).
so in case of j++ the value of the expression is j but as a side effect j gets incremented by 1. So test will receive the value 6,6.
Where am I going wrong here ?
#include<stdio.h>
void test(int x,int y)
{
printf("x = %d\n",x);
printf("y = %d\n",y);
}
int main(void)
{
int i =5;
int j =5;
test(++i,j++);
return 0;
}
$ ./a.exe
x = 6
y = 5
According to my understanding function call provide sequence point i.e all the side effect will be guaranteed to be complete ( after the evaluation of all the arguments, and just before the actual cal).
so in case of j++ the value of the expression is j but as a side effect j gets incremented by 1. So test will receive the value 6,6.
Where am I going wrong here ?