Heinzi1991
Erfahrenes Mitglied
ok hab jetzt alles erledigt und es funktioniert auch schon zu 90% nur das einspeichern klappt nicht so richtig, also ich hab ja drei dateien, zwei dateien schreibt er mir ins struct aber die dritte nicht mehr und leider wei0 ich nicht wo mein fehler liegt!
hier der komplette code:
hier der komplette code:
Code:
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
typedef struct song
{
char tag[3];
char title[30];
char artist[30];
char album[30];
char year[4];
char comment[30];
int genre;
struct song *next;
}PLAYLIST;
PLAYLIST *first = NULL;
int main()
{
FILE *file_m3u;
char meta[129];
char buffer[129];
PLAYLIST Song;
file_m3u = fopen("playlist.m3u", "rb");
char *name_m3u = malloc(sizeof(name_m3u));
while(fgets(name_m3u, 1024, file_m3u) != NULL)
{
if(*name_m3u != '#')
{
char *file_name1 = name_m3u;
int strlength = strlen(file_name1);
file_name1[strlength-1] = '\0';
printf("%s\n", name_m3u);//hilfestellung
FILE *file_mp3 = fopen(file_name1, "rb");
fseek(file_mp3, -128, SEEK_END);
fread(meta, 1, 128, file_mp3);
PLAYLIST *ptr, *ptrv;
if(first == NULL)
{
first = (PLAYLIST*) malloc(sizeof(PLAYLIST));
memcpy(Song.tag, meta, 3);
memcpy(Song.title, meta+3, 30);
memcpy(Song.artist, meta+33, 30);
memcpy(Song.album, meta+63, 30);
memcpy(Song.year, meta+93, 4);
memcpy(Song.comment, meta+97, 30);
first -> next = NULL;
}
else
{
ptrv = first;
while(ptrv -> next != ptr)
ptrv = ptrv -> next;
ptr = (PLAYLIST *) malloc(sizeof(PLAYLIST));
memcpy(Song.tag, meta, 3);
memcpy(Song.title, meta+3, 30);
memcpy(Song.artist, meta+33, 30);
memcpy(Song.album, meta+63, 30);
memcpy(Song.year, meta+93, 4);
memcpy(Song.comment, meta+97, 30);
ptr -> next = ptrv -> next;
ptrv -> next = ptr;
}
}
}
return 0;
}