Hi All,
In below piece of code, I am trying to read the size of a binary file in bytes and assign it to a variable of type uint16_t.
uint16_t readSize;
qDebug()<<"size of a binary file "<<fileName<< "is in bytes"<<f.size ()<<"\n"; ===> 131071 (expected value)
readSize = f.size ();
qDebug()<<"size of a binary file "<<readSize<<"\n";====> 65535 (Incorrect value)
/* updating file size to a struct variable of type uint16_t
req.Size = f.size ();====> 65535 (Incorrect value)
QFile f (fileName);
uint16_t readSize;
f.open (QIODevice::ReadOnly);
qDebug()<<"size of a binary file "<<fileName<< "is in bytes"<<f.size ()<<"\n"; ===> 131071 (expected value)
readSize = f.size ();
qDebug()<<"size of a binary file "<<readSize<<"\n";====> 65535 (Incorrect value)
/* updating file size to a struct variable of type uint16_t
req.Size = f.size ();====> 65535 (Incorrect value)
To copy to clipboard, switch view to plain text mode
When I change readSize data type from int then
readSize = f.size ();
qDebug()<<"size of a binary file "<<readSize<<"\n";====> 131071
readSize = f.size ();
qDebug()<<"size of a binary file "<<readSize<<"\n";====> 131071
To copy to clipboard, switch view to plain text mode
Is this because of data type uint16_t restricting? or size of the file exceeding the range of uint16_t?
Bookmarks