Guest_imported
New member
- Jan 1, 1970
- 0
Here is the code I have so far.
#include <stdio.h>
#include <string.h>
#define MAXLIN 150
int main()
{
FILE *f1;
char string[MAXLIN];
char got[MAXLIN];
static char mname[MAXLIN];
int fi = 0;
f1=fopen("all.m3u", "r"
while ( fgets( string, MAXLIN, f1) != NULL)
if (string[0] != '#')
{
strcpy(got,strrchr(string,'\\'));
strcpy(mname,(&got[1]));
printf("%s",mname);
fi++;
}
return(0);
}
What I'm trying to do is put the mname variable into an array like umame[fi][0], so that I can then move back and forth through it in a loop,
Here is some of the all.m3u file to show structure:
#EXTM3U
#EXTINF:247,2 Unlimited - Twilight Zone
\\csgld420\MUSIC\My Music\2 Unlimited - Twilight Zone.mp3
#EXTINF:355,A-Ha - Take On Me (Tecno Mix)
\\csgld420\MUSIC\My Music\A-Ha - Take On Me (Tecno Mix).mp3
#EXTINF:216,Abc - How To Be A Millionaire
\\csgld420\MUSIC\My Music\ABC - How To Be A Millionaire.mp3
#EXTINF:209,Abc - Look Of Love
\\csgld420\MUSIC\My Music\ABC - Look of Love.mp3
#EXTINF:265,Abc - When Smokey Sings
\\csgld420\MUSIC\My Music\ABC - When Smokey Sings.mp3
#EXTINF:343,AC\DC - For Those About To Rock
\\csgld420\MUSIC\My Music\ACDC - For Those About To Rock.mp3
#EXTINF:211,AC\DC - You Shook Me All Night Long
\\csgld420\MUSIC\My Music\ACDC - You Shook Me All Night Long.mp3
#EXTINF:211,Ace Of Base - All That She Wants
\\csgld420\MUSIC\My Music\Ace Of Base - All That She Wants.mp3
Now my code gives me almost what I want, but I can't seem to put it into any array, I get various errors.
Here is an example of the output from the code I have so far:
2 Unlimited - Twilight Zone.mp3
A-Ha - Take On Me (Tecno Mix).mp3
ABC - How To Be A Millionaire.mp3
ABC - Look of Love.mp3
ABC - When Smokey Sings.mp3
ACDC - For Those About To Rock.mp3
ACDC - You Shook Me All Night Long.mp3
Ace Of Base - All That She Wants.mp3
Which is fine, but I need to wack the CR and the ".mp3" off the end still.
I want to be able to call the array like this in the end.
printf("%s",newname[fi]); /* or newname[32] */
load_amp(newname[fi],0);
I have tried:
strcpy(newname[fi],mname); but it errors and GPF when ran
newname[fi] = mname; same as above
I need the info to look like this in the end:
newname[0] = 2 Unlimited - Twilight Zone
newname[1] = A-Ha - Take On Me (Tecno Mix)
newname[2] = ABC - How To Be A Millionaire
newname[3] = ABC - Look of Love
newname[4] = ABC - When Smokey Sings
newname[5] = ACDC - For Those About To Rock
newname[6] = ACDC - You Shook Me All Night Long
newname[7] = Ace Of Base - All That She Wants
or newname[0][0] = 2 Unlimited - Twilight Zone
I'm not sure,
Please tell me what I'm doing wrong.
If its all wrong, please tell me that as well.
Thank you in advance for any help you can give me.
Scott
#include <stdio.h>
#include <string.h>
#define MAXLIN 150
int main()
{
FILE *f1;
char string[MAXLIN];
char got[MAXLIN];
static char mname[MAXLIN];
int fi = 0;
f1=fopen("all.m3u", "r"
while ( fgets( string, MAXLIN, f1) != NULL)
if (string[0] != '#')
{
strcpy(got,strrchr(string,'\\'));
strcpy(mname,(&got[1]));
printf("%s",mname);
fi++;
}
return(0);
}
What I'm trying to do is put the mname variable into an array like umame[fi][0], so that I can then move back and forth through it in a loop,
Here is some of the all.m3u file to show structure:
#EXTM3U
#EXTINF:247,2 Unlimited - Twilight Zone
\\csgld420\MUSIC\My Music\2 Unlimited - Twilight Zone.mp3
#EXTINF:355,A-Ha - Take On Me (Tecno Mix)
\\csgld420\MUSIC\My Music\A-Ha - Take On Me (Tecno Mix).mp3
#EXTINF:216,Abc - How To Be A Millionaire
\\csgld420\MUSIC\My Music\ABC - How To Be A Millionaire.mp3
#EXTINF:209,Abc - Look Of Love
\\csgld420\MUSIC\My Music\ABC - Look of Love.mp3
#EXTINF:265,Abc - When Smokey Sings
\\csgld420\MUSIC\My Music\ABC - When Smokey Sings.mp3
#EXTINF:343,AC\DC - For Those About To Rock
\\csgld420\MUSIC\My Music\ACDC - For Those About To Rock.mp3
#EXTINF:211,AC\DC - You Shook Me All Night Long
\\csgld420\MUSIC\My Music\ACDC - You Shook Me All Night Long.mp3
#EXTINF:211,Ace Of Base - All That She Wants
\\csgld420\MUSIC\My Music\Ace Of Base - All That She Wants.mp3
Now my code gives me almost what I want, but I can't seem to put it into any array, I get various errors.
Here is an example of the output from the code I have so far:
2 Unlimited - Twilight Zone.mp3
A-Ha - Take On Me (Tecno Mix).mp3
ABC - How To Be A Millionaire.mp3
ABC - Look of Love.mp3
ABC - When Smokey Sings.mp3
ACDC - For Those About To Rock.mp3
ACDC - You Shook Me All Night Long.mp3
Ace Of Base - All That She Wants.mp3
Which is fine, but I need to wack the CR and the ".mp3" off the end still.
I want to be able to call the array like this in the end.
printf("%s",newname[fi]); /* or newname[32] */
load_amp(newname[fi],0);
I have tried:
strcpy(newname[fi],mname); but it errors and GPF when ran
newname[fi] = mname; same as above
I need the info to look like this in the end:
newname[0] = 2 Unlimited - Twilight Zone
newname[1] = A-Ha - Take On Me (Tecno Mix)
newname[2] = ABC - How To Be A Millionaire
newname[3] = ABC - Look of Love
newname[4] = ABC - When Smokey Sings
newname[5] = ACDC - For Those About To Rock
newname[6] = ACDC - You Shook Me All Night Long
newname[7] = Ace Of Base - All That She Wants
or newname[0][0] = 2 Unlimited - Twilight Zone
I'm not sure,
Please tell me what I'm doing wrong.
If its all wrong, please tell me that as well.
Thank you in advance for any help you can give me.
Scott