Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID


We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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 "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
case 'h':
printf("Bad Option: %s
else {
++argv; //increment
--argc; //decrement
return 0;

output.c file

//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.