Skiping whitespace
Ali Çehreli
acehreli at yahoo.com
Sun May 26 16:32:35 PDT 2013
On 05/26/2013 05:03 AM, matovitch wrote:
> I am writting a simple parser for .obj file (mesh) and I would like to
> read 3 floats like this :
>
> 1.1 2.2
>
> 3.3
>
> So I tried file.readf("%*[ \n\t]%f%*[ \n\t]%f%*[ \n\t]%f",&x, &y, &z);
> who works with C function scanf but doesn't work here.
>
> Is there a simple way to parse this text ?
A single space character in the format specifier is a placeholder for
zero or more whitespace characters:
import std.stdio;
void main()
{
float x;
float y;
float z;
auto file = File("deneme.txt");
file.readf(" %s %s %s", &x, &y, &z);
}
Ali
More information about the Digitalmars-d
mailing list