HP 9000 Series 300 Tutorials Manual page 277

Device i/o and user interfacing hp-ux concepts and tutorials
Hide thumbs Also See for HP 9000 Series 300:
Table of Contents

Advertisement

Example Program: SHOW
This example program displays a file taken from the standard input, one screen
at a time. Press the terminal space bar to advance to the next screen.
#include <curses.h>
#include <signal.h>
main(argc,argv)
{
int
argc;
char
*argv [] ;
FILE
*fd;
char
linebuf[BUFSIZ];
int
line;
void
done() ,perror() ,exit();
i f
(argc
!=
2) {
fprintf(stderr, "usage: Is file\n", argv[O]);
exit
(1) ;
}
if
(fd
=
fopen(argv[l] , "r"»
==
NULL) {
perror(argv[l]);
exit(2);
}
signal (SIGINT, done);
initscrO;
noechoO;
cbreakO;
nonlO;
/* enable more screen optimization
idlok(stdscr , TRUE) ;
/* allow insert/delete line */
while (1) {
move(O,O);
for (line
=
0; line < LINES; line++) {
}
if (fgets(linebuf, sizeof linebuf, ·fd)
==
NULL) {
clrtobotO;
done 0 ;
}
move(line,O);
printw("%s", linebuf);
Program Operation
3-13

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents