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
Dear friend
for you, i think you should try to dis assemble the code.
but the dis assemblers are not so worth they can be used to decode the hex to asm but if the actual program was written on C, the dis assembled code will be heavy and very difficult to understand.
and when there are more NOP instructions, the disassembler will show " truncated" so after disassembling you must take care of it
regards
jo
but consida idapro
You say you have a text file that contains: "1 23 35 76 46 77 ...."
You say that 76 is your 4th character. But if 1, 23, 35, 76, 46, 77 are the decimal values of the first characters in the file, then it doesn't look like a text file. The decimal values 1 or 23 does not correspond to characters I would expect to find in a text file.
Of course you can work with tab characters in the simulator. You encode tab characters as '\t' or 9 or "\x09".
hello, if I stock in my file.txt 1\t 23\t 35\t 76\t 46\t 77\t ....how can find 76 (for example) .
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.