#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include "TestArray.h"
Go to the source code of this file.
int TestArray_write_helper |
( |
const char * |
filename, |
|
|
const char * |
label, |
|
|
const void * |
array, |
|
|
int |
elemsize, |
|
|
int |
length, |
|
|
int |
isfp |
|
) |
| |
Definition at line 10 of file TestArray.C.
References LABEL_SIZE.
Referenced by TestArray_write().
18 const char *stype =
"unknown";
19 if ( isfp && elemsize==8 ) stype =
"double";
20 else if ( isfp && elemsize==4 ) stype =
"float";
21 else if ( !isfp && elemsize==8 ) stype =
"int64";
22 else if ( !isfp && elemsize==4 ) stype =
"int32";
23 else if ( !isfp && elemsize==2 ) stype =
"int16";
24 else if ( !isfp && elemsize==1 ) stype =
"int8";
25 printf(
"Writing %s array of length %d to binary file %s\n",
26 stype, length, filename);
27 FILE *fp = fopen(filename,
"wb");
28 if ( fp == 0 )
return -1;
32 fwrite(&isfp,
sizeof(
int), 1, fp);
33 fwrite(&elemsize,
sizeof(
int), 1, fp);
34 fwrite(&length,
sizeof(
int), 1, fp);
35 fwrite(array, elemsize, length, fp);
static const int LABEL_SIZE
const int LABEL_SIZE = 116 |
|
static |