Okay, I was able to get my program to correctly write the raw value of my variable to the file. I am now trying to make another program to allow me to convert the binary data file to a formatted string file just in case I would like to have the data human-readable. Unfortunately, I am getting a strange error when using fread, and I believe my syntax is correct. As a note, the file I am reading from was written with another program using the following snippet of code where avintensity was defined as a long double and outfile was fopened as a "wb" file:
[tt]fwrite(&avintensity,8,1,outfile);[/tt]
Here is the code for my conversion program:
[tt]#include <stdio.h>
int main(int argc,char* argv[])
{
FILE* infile=fopen(argv[1],"rb"
FILE* outfile=fopen(argv[2],"w"
long double tmp=0;
while(!feof(infile))
{
fread(&tmp,8,1,infile);
fprintf(outfile,"% .10Lf\n",tmp);
}
fclose(infile);
fclose(outfile);
return 0;
}[/tt]
And this is the error I get after compiling, linking, and executing:
[tt]> convert data6.dat data6c.dat
convert: no delegate for this image format (data6.dat) [No such file or directory].
convert: Missing an image file name.[/tt]
Thanks for any help.
[tt]fwrite(&avintensity,8,1,outfile);[/tt]
Here is the code for my conversion program:
[tt]#include <stdio.h>
int main(int argc,char* argv[])
{
FILE* infile=fopen(argv[1],"rb"
FILE* outfile=fopen(argv[2],"w"
long double tmp=0;
while(!feof(infile))
{
fread(&tmp,8,1,infile);
fprintf(outfile,"% .10Lf\n",tmp);
}
fclose(infile);
fclose(outfile);
return 0;
}[/tt]
And this is the error I get after compiling, linking, and executing:
[tt]> convert data6.dat data6c.dat
convert: no delegate for this image format (data6.dat) [No such file or directory].
convert: Missing an image file name.[/tt]
Thanks for any help.