[comp.unix.aix] Why does this fail? repost

drd@siia.mv.com (David Dick) (06/21/91)

The program at the end of this posting produces the following
output when run on the three machines given:

RESULTS--

	ARIX (Motorola 68020):

	inch returned 'X' (0x58)

	IBM RS/6000:

	inch returned '' (0x0)

	IBM PS/2 (Intel something):

	inch returned 'X' (0x58)

PROGRAM--

    /* intst -- simple inch() test */

    #include <curses.h>
    #include <stdio.h>

    main()
    {
	int ch;

	initscr();
	move(10,10);
	addch('X');
	move(10,10);
	ch = inch();
	endwin();
	printf("inch returned '%c' (0x%0x)\n",ch,ch);
    }

David Dick
Software Innovations, Inc [the Software Moving Company (sm)]

chem194@csc.canterbury.ac.nz (John Davis) (06/24/91)

In article <1991Jun21.143411.21416@siia.mv.com>, drd@siia.mv.com (David Dick) writes:
> The program at the end of this posting produces the following
> output when run on the three machines given:
> 
> RESULTS--
> 
> 	ARIX (Motorola 68020):
> 
> 	inch returned 'X' (0x58)
> 
> 	IBM RS/6000:
> 
> 	inch returned '' (0x0)
>
> PROGRAM--
> 
>     /* intst -- simple inch() test */
> 
>     #include <curses.h>
>     #include <stdio.h>
> 
>     main()
>     {
> 	int ch;
> 
> 	initscr();
> 	move(10,10);
> 	addch('X');
> 	move(10,10);
> 	ch = inch();
> 	endwin();
> 	printf("inch returned '%c' (0x%0x)\n",ch,ch);
>     }

Welcome to the club - I just found that one too. As far as I 
can see, stdscr->_y is not being initialised properly (in fact
it's nil), resulting in inch() (which derefs _y) grabbing
random chars. If you're real lucky you'll segmentation violation!!!

-----------------------------------------------------------
| o      John Davis - CHEM194@csc.canterbury.ac.nz       o |
| o    (Depart)mental Programmer,Chemistry Department    o |
| o  University of Canterbury, Christchurch, New Zealand o |