I'm looking for some help piping a file (16-bit signed little endian integers raw data) from the command line to my program:
cat rawdata.dat | myprogram
The code works pretty well on Linux, 512 bytes are transformed into 256 ints per loop turn.
If I compile it with MinGW on Windows, only the first 76 values will be transformed correctly. Also the program stops after the first while loop.
Does anybody know what I am doing wrong? I am using Windows 7 64bit + MinGW compiler.
Code:
#include <iostream>
using namespace std;
int main()
{
int BUF_LEN = 512;
char buf[BUF_LEN];
while(!cin.eof())
{
cin.read(buf, BUF_LEN);
int16_t* data = (int16_t*) buf; //to int
for(int i=70;i<85;i++)
{
cout << i << " " << data[i] << endl;
}
}
return 0;
}
Testfile: http://www.filedropper.com/rawdata
Correct values would be:
70 -11584
71 13452
72 -13210
73 -13331
74 13893
75 10870
76 9738
77 6689
78 -253
79 -1009
80 -16036
81 14253
82 -13872
83 10020
84 -5971