Logo
~Apps~
~Projects~
~Contact~

zd.c File Reference

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

Include dependency graph for zd.c:

Go to the source code of this file.


Functions

int main (int argc, char *argv[])

Function Documentation

int main int  argc,
char *  argv[]
 

Definition at line 7 of file zd.c.

References c().

00008 {
00009         FILE *fil;
00010         unsigned char c;
00011         char slask[200];
00012         int i;
00013         long addr = 0;
00014 
00015         if (argc < 2)
00016         {
00017                 printf("Usage: %s <file>\n",*argv);
00018                 exit(-1);
00019         }
00020         if ((fil = fopen(argv[1],"rb")) != NULL)
00021         {
00022                 while (!feof(fil))
00023                 {
00024                         printf("%04lx ",addr);
00025                         *slask = 0;
00026                         for (i = 0; i < 16; i++)
00027                         {
00028                                 fread(&c,1,1,fil);
00029                                 printf(" %02x",c);
00030                                 if (isprint(c & 0x7f))
00031                                         sprintf(slask + strlen(slask),"%c",c & 0x7f);
00032                                 else
00033                                         strcat(slask,".");
00034                                 if (i == 7)
00035                                 {
00036                                         printf(" ");
00037                                         strcat(slask," ");
00038                                 }
00039                         }
00040                         printf("  %s\n",slask);
00041                         addr += 16;
00042                 }
00043                 fclose(fil);
00044         } else
00045                 printf("Couldn't open '%s'...\n",argv[1]);
00046         return 0;
00047 }

Page, code, and content Copyright (C) 2005 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4