I'm having some problems with my code:
int a, b,x, c, d, cdnr ;
char songname[4][3000][30];
char sok[4], avsok[30], cdtitel[4][30], r[30], i;
{ ifstream array2;
array2.open ("array.txt");
array2 >> i;
for(a=1;a<=i;a++){
array2>>cdtitel[a];
array2>>r[a];
for(b=1;b<=r[a];b++)
array2>>songname[a][b];
}
array2.close();
}
for(a=1;a<=i;a++){
cout<<cdtitel[a]<<endl<<endl;
for(b=1;b<=r[a];b++)
cout<<songname[a][b]<<endl;
}
My text file:
3
AAAAAAAA
2
111
222
BBBBBBBBBBb
3
111
222
333
CCCCCCCCCCccc
4
111
222
333
444
The structure is:
Number of CDs
CD title 1
Number of songs
Song name 1
Song name 2
CD title 2
etc...
Output:
AAAAAAAA
2
111
222
BBBBBBBBBBb
3
111
222
333
CCCCCCCCCCccc
4
111
222
333
444
+101 empty lines
The actual output should be:
AAAAAAAA
111
222
BBBBBBBBBBb
111
222
333
CCCCCCCCCCccc
111
222
333
444
It should show the cd title and then the song names, second cd title and song names etc.
I really can't see where the problem is...
Any help would be greatful