Lex and redefining the i/o macros

Ronald Pikkert ronald at atcmp.nl
Mon Jul 16 19:19:16 AEST 1990


>From article <859 at airgun.wg.waii.com>, by lampshir at airgun.wg.waii.com (gregory b. lampshir):


<> char input()
<> {
<> 	int pos;
<> 	char *ch;  
<> 	
<> 	pos=read(filePointerIn,ch,1);
<>  	if(pos==0) return(0); /* needed by lex to signal eof */
<> 	else return(*ch);
<> }
<> 
<> Can any of you lex wizards help me with this one?  What am I doing wrong?

How about initialising the pointer ch? Or just write something like:

 	char ch;  
 	if (read(filePointerIn,&ch,1)!=1) return(0);
  	return(ch);

By the way, how about not using a system call for every single character 
that is to be read?

-
Ronald Pikkert                 E-mail: ronald at atcmp.nl
@ AT Computing b.v.            Tel:    080 - 566880
Toernooiveld
6525 ED  Nijmegen



More information about the Comp.unix.questions mailing list