C
Chad
When I have:
int main(void)
{
int x = 256;
x>>8;
printf("The value is: %d\n", x);
return 0;
}
I get:
[cdalten@localhost ~]$ gcc -g -Wall seq.c -o seq
seq.c: In function 'main':
seq.c:6: warning: statement with no effect
[cdalten@localhost ~]$ ./seq
The value is: 256
However, when I change x from x>>8 to x++
#include <stdio.h>
int main(void)
{
int x = 256;
x++;
printf("The value is: %d\n", x);
return 0;
}
I get:
[cdalten@localhost ~]$ gcc -g -Wall seq.c -o seq
[cdalten@localhost ~]$ ./seq
The value is: 257
The question is, how come something like x>>8 discards the value right
away, but x++ doesn't?
int main(void)
{
int x = 256;
x>>8;
printf("The value is: %d\n", x);
return 0;
}
I get:
[cdalten@localhost ~]$ gcc -g -Wall seq.c -o seq
seq.c: In function 'main':
seq.c:6: warning: statement with no effect
[cdalten@localhost ~]$ ./seq
The value is: 256
However, when I change x from x>>8 to x++
#include <stdio.h>
int main(void)
{
int x = 256;
x++;
printf("The value is: %d\n", x);
return 0;
}
I get:
[cdalten@localhost ~]$ gcc -g -Wall seq.c -o seq
[cdalten@localhost ~]$ ./seq
The value is: 257
The question is, how come something like x>>8 discards the value right
away, but x++ doesn't?