Hi, this is a homework problem where main is being run by another program. We need to make a series of functions for main to use. It takes information that a bank statement would have and basically generates that statement using a series of functions. In the following two functions, entries are added to an array of structs containing all the information, then the arrays are printed in the second function. The problem is that I'm not saving to memory. That or I'm not accessing it correctly. I'm lost on which it is and how to address it. Any help would be great, I'm very new to this and very lost! Thanks!
here is my global information
Code:#include <stdio.h> #include "banklog.h" #define ph 10 #define max 1024 typedef struct banklog{ double amount; const char * category[ph]; const char * date[ph]; const char * description; } banklog; int at = 0;//placeholder for the current struct
here is my function to add new entries
Code:/* Add a record to the bank log with the specified information. Return value: 0 -- successfully added -1 -- unable to allocate space for new entry */ int BANKLOGadd(double amount, const char* category, const char* date, const char* description) { struct banklog banklog[max]; if (amount!=0 && category != 0 && date != 0 && description != 0) { banklog[ amount, *category, *date, *description ]; at++; return 0; } return -1; }
Here is the function to print the list.
Code:void BANKLOGprint() { struct banklog banklog[ph]; int i= 0; for (i=0; i<at; i++) { printf("%8.2lf ",banklog[i].amount); printf("%s ",banklog[i].category); printf("%.*s ", banklog[i].date+2-1); printf("%.20s\n", banklog[i].description); } }



LinkBack URL
About LinkBacks



