Reading a log_file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Reading a log_file

TamuraiTamurai Posts: 1Member
Okay. I have been challenged to write a program that reads a line from different log_files places it in a database and then shows it in a graph. I have no idea where to start. I only know the basics. THis is what I have so far.



main.c file


#include
#include
#include "output.h"
#include "func.h"

// argc recieves # of command line arguements
// argv pointers to strings in which the actual command line arguements are stored
int main (int argc, char *argv[] ) {
int days;
char file;
while ( argc > 1 ) {
if ( argv[1][0] == '-' ) {
switch(argv[1][1]) {
case 'd':
if ( argc > 2 )
days = atoi(argv[2]); //converts to integer
else
print_usage();
++argv;
--argc;
break;
case 'h':
print_usage();
break;
default:
printf("Bad Option: %s
",argv[1]);
print_usage();
}
}
else {
scanf("%s",&file);
}
++argv; //increment
--argc; //decrement
}
return 0;
}

output.c file

#include
//fputs : the null zero is dropped, and a newline character is not added
void print_usage(void) {
fputs("Usage: TEST [-d days] -f log_file
", stderr);
}
//%d integer
void display_output(int total) {
printf("And the total is :%d
", total);
}

func.c file


int sum ( int * array, int n ) {
int i = 0 ;
int big = 0 ;
int small = 0 ;

for ( i = 0 ; i < n ; i++ ) {
if ( i == 0 ) {
big = array[i];
small = array[i];
}
if ( array[i] > big) {
big = array[i];
}
if ( array[i] < small ) {
small = array[i];
}
}
return(big - small);
}



please help


Sign In or Register to comment.