Read line in file until delimiter (space/tab)

  • Thread starter Thread starter Jesse
  • Start date Start date
J

Jesse

I'm having trouble finding a way to read a line from a file until a
space or tab occurs. Currently I'm using

FileStream* fs = new FileStream(path, FileMode::Open);
StreamReader *sr = new StreamReader(fs);

String* stra = sr->ReadLine();

in order to read in floats. I have to put each float on a new line
now, and that is not ideal since my app needs 3 floats at a time to
work its magic. Is there anything I can replace ReadLine() with that
will read in multiple floats on one line. The file will ideally look
like so...

float1 float2 float3
float4 float5 float6
etc.

It currently looks like...

float1
float2
float3
etc.

Thanks for any help you can pass my way!

Jesse
 
Hi Jesse,
Is there anything I can replace ReadLine() with that
will read in multiple floats on one line. The file will ideally look
like so...

You can read entire string by ReadLine and then split it by String::Split
call, passing space and tab chars as separator. Hope it helps.

...
Cheers,
Vadim.
 
Back
Top