Could someone help me with this code. My goal is to create a simple dos program that can read and display the contents of binary help files. I am not looking to create a hex editor or anything like that.
#include <stdio.h> // old c stuff
#include <string.h>
#define CRTWIDTH 80
#define CRTLENGTH 20
int main(int argc, char *argv[])
{
FILE *inFile = NULL;
char fileName[80];
int loop;
int lines;
unsigned char fileBuffer[CRTWIDTH -1];
if(argc == 1)
{
printf("\nUsage [drive]:\\directory\\filename.hlp");
printf("\n--> ");
gets(fileName);
}
else
{
strcpy(fileName,argv[1]);
// open... test file here fopen(fileName, "rb")
// reading contents... help here is needed
while(!feof(inFile))
{
if(loop < sizeof fileBuffer)
fileBuffer[loop++] = (unsigned char)fgetc(inFile);
else
{
for(loop = 0; loop <= sizeof fileBuffer; count++)
printf("%c", fileBuffer[loop]));
// this char isn't cutting it
// blah
}
This is returning the binary info but not the way in which a user can read it. any ideas on how to fix this would be greatly appreciated.