View Full Version : reading a binary file and put each byte of it it in a cell of float array
Alex22
14th November 2015, 17:04
hi all
i have a binary file. i want to read it by Qfile and then put each Byte of it in a cell of float array.
please help. thanks a lot
ChrisW67
15th November 2015, 03:49
What have you tried?
Alex22
15th November 2015, 13:23
What have you tried?
ChrisW67, i want like fread command in C++, to read a binary file in Qt and then put each byte in a cell of a char type array and then cast it to float and plot it by qwt. like this code in C:
//open file
FILE *fp;
if ((fp = fopen(path, "rb")) == NULL)
{
perror("Error opening binary file");
return 1;
}
//read from file to memory
fread(&vm.memory, 1, 65536, fp);
fclose(fp);
ChrisW67
15th November 2015, 20:10
QFile::read() into an existing char buffer or QByteArray
Alex22
16th November 2015, 14:23
QFile::read() into an existing char buffer or QByteArray
thanks a lot ChrisW67, please give me an example with existing char like: char c[1024]
ChrisW67
16th November 2015, 20:18
const int bufferSize = 1024;
char buf[bufferSize];
...
qint64 bytesRead = file.read(buf, bufferSize);
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.