This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

find a char from file.txt

Hello,

I want to find the value of 4th char stocked in a file.txt .

for example . I have a file.txt that contains 1 23 35 76 46 77 ....
i want to return the value of 4th char witch is "76".

PS:In simulator , i can not creat a tab and i can not use pointer.

my final objective is to copy the data from a file to a region in the RAM .

can help me please
thank you

Parents Reply Children
  • Did you read the documentation for scanf() or sscanf()? Have you tried to google for scanf() or sscanf()?

    By the way - why do you separate your numbers with both a tab and a space?

    Why do you want to retrieve just the third number (previously it was only the fourth)? Is this a school assignment?

    Normally, if you save measurements or configuration to a file, you would retrieve a lot more than a single value. And if the file is stored in a flash file system within a microcontroller, it is often better to use binary data, since binary data does not require any extra code to parse and adapt to amount of white-space etc - and binary data takes less room.