February 09, 2005
Is there a better way to test for EOF in a string (char[])?

char c = getchar();
token = toString(c)
if(cast(int)token[0] != 255) // this works (seeking better)
{
..
}

Thanks,
Rev


February 09, 2005
Rev wrote:

> Is there a better way to test for EOF in a string (char[])?
> 
> char c = getchar();
> token = toString(c)
> if(cast(int)token[0] != 255) // this works (seeking better)
> {
> ..
> }

int i = getchar();
if (i != EOF)
{
  char c = i;
  ...
}

--anders