I’m trying to get the floats from a string.
I mean reading line by line from a text file and getting the floats from a line. I found how to read line by line but I couldn’t split the string into floats.
Here is an example input file:
10,10,18,18.1
7,3 ,10,14.2
3,3,5.3,5
I’ve looked at sscanf but I couldn’t do it. Any idea?
From years of experience, I’ve found that scanf is unlikely to do exactly what you want. It’s OK for a quick test program.
One possibility is to use
Str.split:You might need to make the regexp a little tighter if you want to detect invalid input.