Here it is:
Script started on Mon Nov 03 18:25:10 2003
sh-2.05$ ./testprog
Result OK
�sh-2.05$
script done on Mon Nov 03 18:25:14 2003
/ Paul
Mon 2003.11.03 17:18, "Brian Candler" wrote:
> On Mon, Nov 03, 2003 at 06:03:24PM +0100, Paul Diaconescu wrote:
> > The result is 255
>
> Hmm, can you try this one?
> /* Compile and run as:
> * gcc -Wall -o testprog testprog.c
> * ./testprog >/dev/null
> */
>
> #include <stdio.h>
>
> static void testit(char *p)
> {
> unsigned char *p2 = (unsigned char *)p;
> if (putchar(*p2++) == EOF) {
> fprintf(stderr, "Oops, wrong!\n");
> } else {
> fprintf(stderr, "Result OK\n");
> }
> }
>
> int main(void)
> {
> char foo[2];
> foo[0] = '\255';
> testit(foo);
> return 0;
> }