Atari ST series Technical Reference Manual page 102

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

The Control-C key combination not only causes the
Cconrs() function to return, but also terminates the entire
program. This feature makes Cconrs() extremely dangerous,
and suitable only for quick and dirty programs that you write
for your own use. Any program written for use by others
should implement its own input routine in a manner that
doesn't allow the user to exit the program easily by mistake.
Program 5-1 demonstrates some of the character I/O
functions discussed above.
Program 5-1. GCHARDEV.C
/**********************************************/
/*
/*
GCHARDEV.C
/*
/*
Demonstrates some of the GEMDOS
/*
character device functions.
/*
/**********************************************/
flinclude <osbind.h>
^define MAXLEN 80
main()
{
char buf[MAXLEN+3], ch;
0
int len=
;
/* first input a line a character at a time, using Cconin */
Cconws("Enter a line of text, and hit Ret ur n:\n\n\r");
do /* keep getting characters */
if ( (ch=Cconin()) !=
buf[len++]=ch;
else
{
Cconws(" \010");
0
if (len>
)
len— ;
} w h i l e ( (ch!=13) && (len<MAXLEN) ); /* do til CR or end of line */
buf[len]=0; /* terminate line with ASCII */
Cconws("\n\nYour line of text was:\n\r");
Cconws(buf);
p rintf("\nAnd it was %d characters long\n\n\n",len);
/* Now, input the whole line at a time */
Cconws("Enter another line of text, and hit Return:\n\n\r");
b u f [0]=MAXLEN;
len =Cconrs(buf);
2
0
buf[len+
]=
;
C conws("\n\nYour line of text was:\n\r");
Cconws(buf+2);
printf("\nAnd it was %d characters long\n",len);
/* if you're running this from the Desktop, you may want to
add a pause to give the user a chance to read the output */
Cconws("\n\n\rPress any key to end");
Cconin();
)
end of GCHARDEV.C *****/
94
CHAPTER 5
/* For GEMDOS macro definitions */
/* maximum input line length */
8
) /* if this isn't a backspace, */
/* add the character to the buffer */
/* if it is a backspace, */
/* rub out last character...*/
/* and if there are any chars to delete */
/* delete one */
*/
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents