HP 9000 Series 300 Tutorials Manual page 288

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: EDITOR
This program is a very simple screen-oriented editor that is similar to a small
subset of vi. For simplicity, the stdscr window is also used as the editing
buffer.
#include <curses.h>
#define CTRL(c) ('c'&037)
main(argc,argv)
{
char
**argv;
int
i,n,l;
int
c;
FILE
*fd;
if (argc
!=
2) {
}
fprintf(stderr,"Usage: edit file\n");
exit(l);
fd
=
fopen(argv[l] ,"r");
if (fd
==
NULL) {
perror(argv[l]);
exit(2);
}
initscrO;
cbreakO;
nonlO;
noechoO;
idlok(stdscr, TRUE);
keypad (stdscr, TRUE);
/* Read in the file */
while «c
=
getc(fd»
!=
EOF)
addch(c);
fclose(fd);
move(O,O);
refreshO;
editO;
/* Write out the file */
fd
=
fopen(argv[l] ,"W");
3-24
Program Operation

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents