[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q] Tracefile Conversion



Dear Seniors

I'm trying to convert ~ns/tcl/ex/example-trace to normal ascii file. 

Below code is my first workout, and it seems not working. The result is so big.
(first field is time and next field is size)
 
What's wrong ?

And If you have converter programs(that is, from ascii to bin and bin to ascii)
can I have a copy of it ?

Thanks

======[code]==========

#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>

int main(int argc, char *argv[])
{
        unsigned int time;
        unsigned int size;
        int pos;
        FILE *file;
        file=fopen(argv[1],"r");
        for(pos=0;pos<10;pos++)
        {
                fread(&time,4,1,file);
                fread(&size,4,1,file);
                printf("%10u %10u\n",htonl(time), htonl(size));
        }
}

=====[result]===========
porce.kaist.ac.kr porce:/home/porce> gcc x.c -o x ; x e | more
1937006962 2002874995  
   8847700   21233971
  21758263   22544703
  21954895   19923296
  18153799   20578610
  19792204   19792198
  19595607   19267889
  21823771   20578606
  19398949   28967425
        65  620757129
=====================