From: Nate K. <nk...@ro...> - 2006-07-26 16:24:45
|
Hello, Your fread statement is incorrect. To read in the version number use fread(&data,4,1,input). Check the manpage for fread. -nate On 7/19/06, Dustin Cannon <dus...@gm...> wrote: > > Hi all, > > In the previous email I sent. The line > printf("version number:%s\n", data); > > > should be > printf("version number:%f\n", data); > > the %s was a type-o, so my problem isn't that I accidentally tried to print > it as a string ;) > > -Dustin- > > previous message: > > Hi, > > I need to extract info from a .gzb file. I have read the description of > gzbuilder's output file format. I tried doing a simple extraction of the > version number, which to my understanding should be the first 4 bytes in the > file. I used code like this: > > gzb_extract(const char *filename) { > > FILE *input; > size_t n; > float data; > > input = fopen(filename, "rb"); > if (input == NULL) { > perror("gzb_extract(): couldn't open input file"); > return -1; > } > > n = fread(&data, 1, 4, input); > if (n != 0) { > data = (float) ntohl((uint32_t) data); // convert to host byte order > data /= 1000; // take out numerical constant > printf("version number: %s\n", data); > } > > fclose(input); > } > > However, the printed results don't seem to make sense. And a hex dump of > the gzb file doesn't seem to match what my program is showing when I print > out those first 4 bytes in hexadecimal. > > If anyone can offer some insight or perhaps tell me if there is a flaw in > the way I am trying to extract the info it would be much appreciated. > Thanks! > > -Dustin- > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > _______________________________________________ > Playerstage-gazebo mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-gazebo > > > |