i've been given a binary file to open and donot know what it contains except that it has floats, ints and char[x] in it. I've built a struct to hold the data. just do not know how to read it. The first and second time through the loop works good. Get funcky stuff after that.
#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace std;
#using <mscorlib.dll >
using namespace System;
struct record
{
int s_Nums;
char s_Desc[25];
float s_Cost;
float s_Time;
int s_Made;
int s_Part;
};
void main()
{
FILE *f_Ptr;
struct record s_Test;
f_Ptr = fopen("V.DAT"," rb");
for (int x = 0; x <= 5; x++)
{
fread(&s_Test, sizeof(struct record), 1, f_Ptr);
printf("\n\t %i ", s_Test.s_Nums);
printf("\n\t %s ", s_Test.s_Desc);
printf("\n\t %.2f ", s_Test.s_Cost);
printf("\n\t %.2f ", s_Test.s_Time);
printf("\n\t %i ", s_Test.s_Made);
printf("\n\t %i \n", s_Test.s_Part);
printf("\n\t\n" );
}// End of for
fclose(f_Ptr);
}// End of main
this is the file data inside of the binary file called "V.DAT"
compressor ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌR¸†@33“AÎ y
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌq=A 9 piston ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ)\©A J
gear n ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌ̸? generator ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌìQTAÍÌ´Av |
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌq=A clamp g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌÃõh? ë pad p g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ…ë> à coil g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ×£Ð@ J
gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌ̸? f gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌHá:? " mixer tor ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌ33AÍÌ”A?
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ®G5A clamp g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌÃõh? ú moter g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ…ë£A à coil g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ×£Ð@ J
gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌ̸? f gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌHá:? ' flashlight ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌ ffF@
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ
׃? Š bulb ng ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ®Gá= lense g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ=
W> 2 grinder ht ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌ 333? Â morter ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌq=Ê? Ê pestle ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌHá
@ : radio r ht ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌìQ˜?ff–@4 ³ capacitor ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÃõ¨? Ë resister ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌ•? Í resister ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌq=ê? Ñ resister ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌR¸ž? r speaker ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌ=
§@ ö push button ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ Ì¸>
#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace std;
#using <mscorlib.dll >
using namespace System;
struct record
{
int s_Nums;
char s_Desc[25];
float s_Cost;
float s_Time;
int s_Made;
int s_Part;
};
void main()
{
FILE *f_Ptr;
struct record s_Test;
f_Ptr = fopen("V.DAT"," rb");
for (int x = 0; x <= 5; x++)
{
fread(&s_Test, sizeof(struct record), 1, f_Ptr);
printf("\n\t %i ", s_Test.s_Nums);
printf("\n\t %s ", s_Test.s_Desc);
printf("\n\t %.2f ", s_Test.s_Cost);
printf("\n\t %.2f ", s_Test.s_Time);
printf("\n\t %i ", s_Test.s_Made);
printf("\n\t %i \n", s_Test.s_Part);
printf("\n\t\n" );
}// End of for
fclose(f_Ptr);
}// End of main
this is the file data inside of the binary file called "V.DAT"
compressor ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌR¸†@33“AÎ y
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌq=A 9 piston ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ)\©A J
gear n ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌ̸? generator ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌìQTAÍÌ´Av |
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌq=A clamp g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌÃõh? ë pad p g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ…ë> à coil g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ×£Ð@ J
gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌ̸? f gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌHá:? " mixer tor ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌ33AÍÌ”A?
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ®G5A clamp g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌÃõh? ú moter g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ…ë£A à coil g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ×£Ð@ J
gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌ̸? f gear g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌHá:? ' flashlight ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌ ffF@
housing ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ
׃? Š bulb ng ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ®Gá= lense g ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌ=
W> 2 grinder ht ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌ 333? Â morter ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌq=Ê? Ê pestle ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÌÌHá
@ : radio r ht ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌìQ˜?ff–@4 ³ capacitor ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌÃõ¨? Ë resister ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌ•? Í resister ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌq=ê? Ñ resister ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌR¸ž? r speaker ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ÌÌÌ=
§@ ö push button ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ Ì¸>
Comment