Hi all
I have a newbie problem. The array "hours_match" is not being filled correctly. I dont know why. On the first printf i see that's OK, but on the second it's not. I have this code (please see the BOLD part).
void populate()
{
int i=0;
char line [ MAX_LINE_SIZE ];
char date[12];
char hour[12];
count = 0;
files_match and hours_match (from now on, simply 'match') are pointers to arrays of pointers to arrays of characters. You are initialing match, but you aren't initializing the pointers inside the array to point to valid memory locations. Instead, you're giving them all the memory location of fileName/hour. Every element in match points to this array.
EDIT: Oh, yeah. Don't use C allocation. We have facilities for that stuff, now. It's called 'new' operator.
It can really make your life easier because your line: files_match=(char**)calloc (MAX_MATCHES,sizeof(char*));
can be changed to: files_match = newchar*[MAX_MATCHES];
The new operator automatically allocate the necessary amount of memory.