Ta en titt på denna koden är ni snälla
Försöker göra ett litet program i ansi C som ska jämföra två m3u spellistor och skapa en ny fil med skillnaden mellan dem. Jag är knappast en avancerad programmerare så koden vimlar säkert av dåliga lösningar, men hur som helst har jag tre fel som jag inte förstår mig på! Kompilatorn säger rad 80, 116, 152. Testa gärna att kompilera själv.
Skulle verkligen uppskatta lite hjälp med de här tre felen!
(bekymra er inte över att kolla på resten av programmet såvida ni inte har jättemycket ork)
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
char oldfilepath[99];
char newfilepath[99];
char append[450];
char index[7] = "#EXTM3U";
char oldarray[25000][300];
char newarray[25000][300];
unsigned int x=1;
unsigned int y=1;
int fr=1;
int columns;
FILE *old;
FILE *new;
FILE *output;
void readfiles(void);
void compare(void);
void out(char *append);
main()
{
system("cls");
gotoxy(2,2);
printf("This program will compare an old and a new m3u playlist, and build a new /n m3u playlist-file which is placed in the same directory as this program and named \"difference.m3u\" with \n all tracks that are missing in the old m3u file from the new one. Press spacebar to continue!");
while (getch() != ' ');
system("cls");
gotoxy(4,4);
printf("Location of old m3u file (just filename for same folder) > ");
scanf("%99s", &oldfilepath);
gotoxy(4,4);
printf("Location of new m3u file (just filename for same folder) > ");
scanf("%99s", &newfilepath);
readfiles();
compare();
if(fr==1)
{
printf("There was no difference between the playlists!");
printf("Press <spacebar> to exit...");
while (getch() != ' ');
exit(1);
}
getch();
return(0);
}
void readfiles()
{
unsigned long size;
unsigned long position=1;
gotoxy(4,4);
printf("Reading old m3u file to memory...");
if ((old=fopen(oldfilepath, "rb"))== NULL)
{
fprintf(stderr, "Could not open old m3u file!\n");
getch();
exit(1);
}
fseek(old,0,2);
size=ftell(old);
while(position < size)
{
fread(oldarray[y][x], 1, 1, old);
if(oldarray[y][x]=="\n")
{
y++;
x=0;
}
x++;
position++;
gotoxy(38,4);
printf("%ld", size-position);
}
oldarray[y][1]=EOF;
fclose(old);
gotoxy(4,5);
printf(" done. ");
gotoxy(4,4);
printf("Reading new m3u file to memory...");
gotoxy(4,5);
printf(" ");
if ((new=fopen(newfilepath, "rb"))== NULL)
{
fprintf(stderr, "Could not open new m3u file!\n");
getch();
exit(1);
}
fseek(new,0,2);
size=ftell(new);
position=1;
while(position<size)
{
fread(newarray[y][x], 1, 1, new);
if(x=="\n")
{
y++;
x=0;
}
x++;
position++;
gotoxy(38,4);
printf("%ld", size-position);
}
newarray[y][1]=EOF;
columns=(y-1);
fclose(new);
gotoxy(4,5);
printf(" done. ");
gotoxy(4,6);
printf("The program will now build a new m3u file.");
printf("Press <spacebar> to continue...");
while (getch() != ' ');
system("cls");
}
void compare()
{
int ok;
y=1;
while(newarray[y][1]!=EOF) {
ok=1;
x=1;
while((strcmp(newarray[y][], oldarray[x][]))!=0)
{
x++;
if (oldarray[1][x]==EOF)
{
ok=0;
break;
}
}
if (ok==0)
{
x=1;
while(newarray[y][x] != EOF) {
append[x] = newarray[y][x];
x++;
out(append);
}
}
y++;
gotoxy(4,4);
printf("Index: %-6d", (columns-y));
}
gotoxy(4,5);
printf("Done.");
}
void out(char *append)
{
if(fr==1)
{
output=fopen("difference.m3u", "ab");
fwrite(&index, sizeof(char), 7, output);
putc(13, output);
}
fwrite(&append, strlen(append), 1, output);
}