Results 1 to 10 of 10

Thread: Read binary file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Read binary file

    Hi,
    I am with problem in the reading of a binary file.
    I made thus:

    Qt Code:
    1. #include <QApplication>
    2. #include <QDataStream>
    3. #include <QFile>
    4. #include <QVector>
    5.  
    6. #include <iostream>
    7. using namespace std;
    8.  
    9. int main(int argc, char *argv[]) {
    10.  
    11. QApplication app(argc, argv);
    12.  
    13. QFile file("wavemin_501ns.ad");
    14. file.open(QIODevice::ReadOnly);
    15. QDataStream in(&file);
    16.  
    17. qint64 tam = file.size();
    18. qint64 ns = tam/sizeof(float);
    19. QVector<float> vet(tam);
    20. in >> vet;
    21.  
    22. for (int i = 0; i < 50; i++)
    23. cout << vet[i] << " " << i << endl;
    24. cout << ns << endl;
    25.  
    26. return 0;
    27. }
    To copy to clipboard, switch view to plain text mode 

    But the values returned for vet[] are not equal to the values of binary file.
    Somebody can help me, please?
    Thank you.
    Last edited by wysota; 10th January 2008 at 23:34. Reason: missing [code] tags

Similar Threads

  1. How can I read Binary files with Qt
    By geo_saleh in forum Qt Programming
    Replies: 2
    Last Post: 16th August 2007, 10:37
  2. How to read text only as it is from file
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2007, 08:47
  3. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  4. Sending Binary File with QFTP
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 7th March 2007, 18:10
  5. Replies: 13
    Last Post: 1st June 2006, 14:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.