Go Down

Topic: reading information from sd card (Read 2 times) previous topic - next topic

victorfb

I have a text file stored on a sd card with information that I need to use on my program. How can I read the values one by one so I can use this information?
Thank you

PeterH

You need to know how the numbers are encoded in the file (one number per line? comma separated list? etc) and then read the relevant bytes from the file into a char array and parse the resulting string.
I only provide help via the forum - please do not contact me for private consultancy.

victorfb

they are separated by commas. but how can I do that, is there a code or command to do that?

PaulS

Quote
but how can I do that, is there a code or command to do that?

What is "that"? Google returned an overwhelming number of hits when searching for "that".

PeterH


they are separated by commas. but how can I do that, is there a code or command to do that?


There are various approaches open to you, but the simplest one is to read the file character by character. If the character is not a comma, append it to a char array buffer. If it is a comma, parse the content of the buffer to a number and clear the buffer. This will give you a sequence of numbers read from the file. I assume you know what to do with the numbers from there on.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up