私は Windows で GCC コンパイラ (コードブロック) を使用しています。取得しているデータは UNIX マシンからのものなので、すべてビッグエンディアンです。使用する前に、リトルエンディアンに交換する必要があります。そして、私はダムになりますが、これを機能させることはできません. 使用する
temp = ntohl(fileBuf[N*i+j]);
また
_byteswap_ulong(fileBuf[N*i+j]);
ゼロのみを返します。私が事実として知っていることは間違っています。
受信データは、32 ビット整数 (米国の一部の標高データ) の単なる文字列です。どんな助けでも大歓迎です
編集:ここはかなり新しいですが、コードが役立つかどうかはわかりませんでした
typedef unsigned char BYTE
int main()
{
long int temp;
int i,j;
ofstream myFile;
myFile.open("fixed4.txt");
const char *filePath = "input2";
BYTE *fileBuf;
FILE *file = NULL;
if ((file = fopen(filePath, "rb"))==NULL)
cout<< "File could not be opened successfully" << endl;
else
cout << "File Opened successfully" << endl;
long fileSize = getFileSize(file);
fileBuf = new BYTE[fileSize];
//BYTE *flipped;
//flipped = new BYTE[fileSize];
fread(fileBuf, fileSize, 4, file);
for (i=0; i<N; i+=1){
for (j=0; j<N; j+=1){
temp = _byteswap_ulong(fileBuf[N*i+j]);
grid[i][j]=binaryToBase10(temp);
// more code here but it isn't important....