Re: Good Tutorials
On 2008-09-23, Amkcoder <frontal_lobe_d estroyer@yahoo. comwrote:
On my system, it does indeed output 666, followed by a "command
not found" regarding your system() call. I'm not sure what this
code demonstrates, though, other than that one can take this:
puts("666")
And make it intrinsicly non-portable, rife with undefined
behavior, inefficient and unmaintainable to boot.
But hey, you're the expert.
(My compiler also has this to say:
usenet.c: In function ‘main’:
usenet.c:9: warning: format ‘%d’ expects type ‘int’, but argument
2 has type ‘long unsigned int’
usenet.c:10: warning: implicit declaration of function ‘system’
usenet.c:11: warning: control reaches end of non-void function
but it hasn't been dealing with C code for as long as you.)
(Also, FWIW, it's incorrect on the first warning - the value
yeilded by the sizeof operator is technically a size_t. I'm
guessing since all the world's a x86, it doesn't matter.)
--
Andrew Poelstra apoelstra@wpsof tware.net
Only GOD may divide by zero. That is how he created black holes.
-Veselin Jungic
On 2008-09-23, Amkcoder <frontal_lobe_d estroyer@yahoo. comwrote:
So if you have a x86 based processor, which you most likely do,
compile and run the following:
It will print out the value 666, and the size (in bytes) of a short
int,
on your x86 system. Enjoy:
>
#include <stdio.h>
>
int main() {
short int a;
unsigned char *b=(unsigned char *)&a;
*b=154;
*(b+1)=2;
printf("%d \n",a);
printf("%d bytes for short int \n",sizeof(shor t int));
system("pause") ;
}
compile and run the following:
It will print out the value 666, and the size (in bytes) of a short
int,
on your x86 system. Enjoy:
>
#include <stdio.h>
>
int main() {
short int a;
unsigned char *b=(unsigned char *)&a;
*b=154;
*(b+1)=2;
printf("%d \n",a);
printf("%d bytes for short int \n",sizeof(shor t int));
system("pause") ;
}
not found" regarding your system() call. I'm not sure what this
code demonstrates, though, other than that one can take this:
puts("666")
And make it intrinsicly non-portable, rife with undefined
behavior, inefficient and unmaintainable to boot.
But hey, you're the expert.
(My compiler also has this to say:
usenet.c: In function ‘main’:
usenet.c:9: warning: format ‘%d’ expects type ‘int’, but argument
2 has type ‘long unsigned int’
usenet.c:10: warning: implicit declaration of function ‘system’
usenet.c:11: warning: control reaches end of non-void function
but it hasn't been dealing with C code for as long as you.)
(Also, FWIW, it's incorrect on the first warning - the value
yeilded by the sizeof operator is technically a size_t. I'm
guessing since all the world's a x86, it doesn't matter.)
--
Andrew Poelstra apoelstra@wpsof tware.net
Only GOD may divide by zero. That is how he created black holes.
-Veselin Jungic
Comment