I'm fairly new to C and have been doing pretty good up until arrays. I understand the basics of them but not exactly how to use and impliment them in more complicated ways.
I am trying to write a program that will display a table of strings and intigers from an input file that contains both, converting the time to the standard minute:second format in a seperate function.
It should display the first the song number, then the time, then the song name.
Like this:
[ 6] 8:17 Don't Get Fooled Again
This is what I have so far.
vvvv
This is just the array delclarations.
char names[99][28]= {" "};
int time[99]={0};
Here it starts.
void fillTable(char names[], int time[], int count, int seconds)
{
FILE *inp;
int *status;
char list[99];
inp = fopen("songdata.txt", "r");
count=0;
while(status != EOF);
{
status = fgets(list, 80, inp);
fscanf(inp, "%d", &seconds);
list[count] = names[count];
seconds = time[count];
printf("[%d]", count);
++count;
}
fclose(inp);
}
/*Time Calculator*/
void showTime(int time[],int min, int sec, int count)
{
int index, seconds;
for (index=0; index < count; index++)
{
time[count] = seconds;
min = (seconds/60);
sec = (seconds%60);
printf("%2d:%02d", min, sec);
}
}
/*Table Display*/
void showTable(int time[], char names[], int count, int min, int sec)
{
int index;
int column[99];
for (index=0; index < count; index++)
{
printf("%s", &names[index]);
}
}
/*Main Function Start*/
int main (void)
{
int sec, min, count;
showTable(time, *names, count, min, sec);
showTime(time, min, sec, count);
return(0);
}
Nothing aside from the initial time function is working (don't even know if that for loop is doing what I want it to.:sad:
I know it's a bit long, but help is much appreciated.