Read line in file until delimiter (space/tab)

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
 
V

Vadim Melnik

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top