Commit b235963b authored by Lindsay Knupp's avatar Lindsay Knupp
Browse files

Pre-lab 10.1 completed

parent 1fbc381b
......@@ -22,9 +22,9 @@
# compiler
CC = gcc
CFLAGS = -g -Wall
CFLAGS = -std=gnu99 -g -Wall
EXE = file_stat read_dir
EXE = file_stat read_dir fdump
all: $(EXE)
......@@ -40,5 +40,11 @@ read_dir: read_dir.o
read_dir.o: read_dir.c
$(CC) -c $(CFLAGS) read_dir.c
hexdump.o: hexdump.h hexdump.c
$(CC) $(CFLAGS) -c hexdump.c -o hexdump.o
fdump: fdump.c hexdump.o
$(CC) $(CFLAGS) fdump.c hexdump.o -o fdump
/bin/rm -f *~ *.o core $(EXE)
......@@ -7,10 +7,42 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "hexdump.h"
#define MAXLEN 20
int main(int argc, char* argv[]){
FILE *fp;
char filename[MAXLEN];
unsigned int offset;
unsigned int size;
unsigned char buffer[256];
if (argc < 4){
printf("Correct usage: %s [filename] [offset] [size]\n",argv[0]);
else {
strcpy(filename, argv[1]);
offset = atoi(argv[2]);
size = atoi(argv[3]);
fp = fopen(filename, "r+");
for (int i =0; i<size;i++){
buffer[i] = fgetc(fp);
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment