Txt file size difference between C++ and Arduino IDE

Could you check the size of the attached file please?
Why I got in c++ 105 bytes
This code of cpp

in_file.seekg(-1, ios::end);
int file_size = in_file.tellg();
   cout<<"Size of the file is"<<" "<< file_size<<" "<<"bytes";

And in arduino I got on 106 bytes Why?

 unsigned char size;                   
 in_file.read(&size,1);
 Serial.println(size);

newtest.txt (106 Bytes)

The size of the file is 106 bytes.

I believe that should be a 0 instead of -1. You could have a look at this example.

How does reading a byte from a file give the file size?

I am not of what you are asking but did you start counting at 0 or 1. In computers zero is actually a value In the people system it is nothing. If you look at 0xF, starting your count from zero will give you 15 in decimal it will give you 16, it depends on your starting point and what you are doing with the number. If it is the compiler they are different and there is no guarantee they will come with the same number of bytes of code. Try Serial.print("Hello"); Then try Serial.print(F("Hello")); the output is the same the memory counts will be different. Hopefully that helps.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.