home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega CD-ROM 1
/
megacd_rom_1.zip
/
megacd_rom_1
/
MAGAZINE
/
PROGJOUR
/
PJ_9_4.ZIP
/
V_GETS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-03
|
718b
|
31 lines
/* v_gets.c- Get String from Viewport */
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <tools/viewport.h>
int v_gets( viewport *v, int n, char *s )
{
/* Copy at most n-1 characters into s, starting at current cursor
* position into s. Return number of characters read.
*/
char *start = s;
if( v->magic != VMAGIC )
return 0;
while( --n > 0 )
{
*s++ = v_getc( v );
if( !v_advance(v) ) /* then we just read the last character */
{ /* on the line */
*s = '\0';
return 0;
}
}
*s = '\0';
return (s - start);
}