www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - ungetc returns c?

reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
Anyone know why ungetc in std.stream returns the input character? I'm 
thinking of changing that to
  void ungetc(char c)
and
  void ungetcw(wchar c)
May 31 2005
next sibling parent reply Sean Kelly <sean f4.ca> writes:
In article <d7ipim$12t$1 digitaldaemon.com>, Ben Hinkle says...
Anyone know why ungetc in std.stream returns the input character? I'm 
thinking of changing that to
  void ungetc(char c)
and
  void ungetcw(wchar c)
I can't think of any reason I'd want the input character from an unget. I say change it. Sean
Jun 01 2005
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Sean Kelly wrote:

Anyone know why ungetc in std.stream returns the input character? I'm 
thinking of changing that to
 void ungetc(char c)
and
 void ungetcw(wchar c)
I can't think of any reason I'd want the input character from an unget. I say change it.
It does in C, so I guess that's why it does in D too. SYNOPSIS #include <stdio.h> int ungetc(int c, FILE *stream); RETURN VALUES The ungetc() function returns the character pushed-back after the conversion, or EOF if the operation fails. So it seems the main reason for the return value in C, is to have somewhere quick to return an error code in ? --anders
Jun 01 2005
prev sibling parent reply SeeSchloss <ng seeschloss.org> writes:
On Tue, 31 May 2005 18:47:47 -0400, Ben Hinkle wrote:

 Anyone know why ungetc in std.stream returns the input character?
char c = stream.ungetc (stream.getc ()); ? Not sure if it's really important, but it's the only use I see.
Jun 01 2005
parent "Ben Hinkle" <bhinkle mathworks.com> writes:
"SeeSchloss" <ng seeschloss.org> wrote in message 
news:pan.2005.06.01.18.18.51.756416 seeschloss.org...
 On Tue, 31 May 2005 18:47:47 -0400, Ben Hinkle wrote:

 Anyone know why ungetc in std.stream returns the input character?
char c = stream.ungetc (stream.getc ()); ? Not sure if it's really important, but it's the only use I see.
OK. might as well keep it the way it is.
Jun 02 2005