6 years, 7 months ago.

Reading Init File

My Init File for example is:

/assign this variables

var1=13

var2=179

I want to read this text file on my mbed and want to assing the number to the name of the variable. I already declared var1 and var2. I don't want to read the lines starting with

Can you clarify what your question is? I don't see one in this post.

posted by Sarah Marsh 27 Sep 2017

1 Answer

6 years, 7 months ago.

Jordy,

I agree with Sarah, it is hard to tell exactly what you are looking for. Probably your post was visually damaged in your note. Be sure to review the "Editing tips" just to the bottom right of the edit box, where you can learn to wrap your code samples to show up with a better appearance.

Your profile says you have the LPC1768 module, which supports LocalFileSystem, so you can use fopen, fread, and fclose toward your goal. Any many mbed modules also support external USB sticks and microSD cards, with the right hardware interfaces and libraries expanding your reach.

if you read a line from a file into a buffer, you could parse it using custom code, or you might look at the strtok function to split on the '=' sign.

You might also search for other examples, for folks that use "ini" file format, and other formats.