www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - testing for eof

reply Rev <Rev_member pathlink.com> writes:
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
Feb 09 2005
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
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
Feb 09 2005