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
Then you are not talking about picking up the value of the fourth character in the file, but the fourth number. That is a completely different thing.
scanf() can be used, but I think you should just retrieve characters one by one until you start getting the digits for the fourth number. Either convert manually, or store in a bugger and use sscanf() or atol() to convert.
detail, i want to create a file.txt ("log >>file.txt") ;
after that, i want to stock in file printf(" %d\t %d\t %d\t %d\n ",a,b,c,d); with c=120
and finally(in other function) how can i retrieve "c" i.e i will have c=120
how can i use scanf or sscanf?
thank you.
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.