Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!ncr-sd!greg From: greg@ncr-sd.UUCP (Greg Noel) Newsgroups: net.unix-wizards Subject: Re: -ltermcap Message-ID: <923@ncr-sd.UUCP> Date: Mon, 4-Aug-86 19:20:55 EDT Article-I.D.: ncr-sd.923 Posted: Mon Aug 4 19:20:55 1986 Date-Received: Tue, 5-Aug-86 01:47:34 EDT References: <2773@mit-eddie.MIT.EDU> <2565@rsch.wisc.edu> Reply-To: greg@ncr-sd.UUCP (Greg Noel) Organization: NCR Corporation, San Diego Lines: 26 In article <2565@rsch.wisc.edu> dave@rsch.wisc.edu (Dave Cohrs), answering an article from shawn@mit-eddie.MIT.EDU (Shawn F. Mckay), writes: >.... The declaration for tgetstr is: > char * tgetstr(id, area) > char *id, **area; >Note the '**area'. So you want to do: >{ > char buff[20]; > char *bufptr = buff; > (void) tgetstr("cl", &bufptr); >} Almost right. The advance of the buffer pointer is actually a \side-effect/, and not the value (the semantic result) of the function. It is documented the way it is so that programmers will be sure to allocate enough space to hold any strings that tgetstr \might/ wish to store there, but it is the return value from tgetstr that must be used for the string. That is, you need to say: char buff[20]; char *bufptr = buff; char *cl_ptr; cl_ptr = tgetstr("cl", &bufptr); This will make the code compatible with the SysV terminfo emulation of termcap, which has its own area for storing the strings, and doesn't copy them into the buffer or update the pointer. -- -- Greg Noel, NCR Rancho Bernardo Greg@ncr-sd.UUCP or Greg@nosc.ARPA