Ok guys, I'm back with new code. I got help from my professor on the problem, but the USB drive I'm using deleted all of his work and I can't remember what he did to get it all to work. I need to get the file (titled lab2.dat):
This is a test of lab2
Special characters are:
to print chars with spaces between and the hex representation beneath them. So far I am having a lot of trouble remembering what he did. Since my class is very new to C, I know it couldn't have been hard or complex, but since my class is new to C, I don't know what he did. Can anyone help me?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int findend(char *);
int charcount = 0;
const int MAX = 81;
int main(void){
int i = 0;
char input[MAX] = "lab2.dat";
FILE *file = fopen (input, "r");
if ( file == NULL ) {
perror ( "File open failure" );}
else{
while(fgets(input, sizeof input, file)!=NULL){
fprintf(stdout, "%s", input);//print the file out
for(i = 0; i < (MAX); i++)
if (input[i] != 0x09)
fprintf(stdout, "%c ", input[i]);
else
fprintf(stdout, "\\t ");
}
for(i = 0; i < MAX; i++)
fprintf(stdout, "%00x ", input[i]);
}
system("PAUSE");
}