Hello, I'm new to cpp and to the forums. Thanks in advance for any help.
I'm writing a program that's supposed to sort several albums as well as the songs within these albums alphabetically. I'm not to the point of sorting yet, I'm still trying to get the data stored in my struct correctly. This data is read in from a text file. The first two lines are read in as album name and album year and saved to strings in a struct. The songs are then read into an array of strings in the same struct. The end of each album is demarcated by a row of ='s. The next album begins on the next line. There are 5 albums with a maximum of 30 songs in each album.
I'm getting a segmentation fault about halfway through the third album. Any insight you guys may provide is appreciated.
The Beatles White Album
Year: 1968
1. Back in the U.S.S.R.
2. Dear Prudence
3. Glass Onion
4. Ob-La-Di, Ob-La-Da
5. Wild Honey Pie
6. The Continuing Story of Bungalow Bill
7. While My Guitar Gently Weeps
8. Happiness Is a Warm Gun
9. Martha My Dear
10. I'm So Tired
11. Blackbird
12. Piggies
13. Rocky Raccoon
14. Don't Pass Me By
15. Why Don't We Do It in the Road?
16. I Will
17. Julia
18. Birthday
19. Yer Blues
20. Mother Nature's Son
21. Everybody's Got Something to Hide Except Me and My Monkey
22. Sexy Sadie
23. Helter Skelter
24. Long, Long, Long
25. Revolution 1
26. Honey Pie
27. Savoy Truffle
28. Cry Baby Cry
29. Revolution 9
30. Good Night
===============================
Abbey Road
Year: 1969
1. Come Together
2. Something
3. Maxwell's Silver Hammer
4. Oh! Darling
5. Octopus's Garden
6. I Want You (She's So Heavy)
7. Here Comes the Sun
8. Because
9. You Never Give Me Your Money
10. Sun King
11. Mean Mr. Mustard
12. Polythene Pam
13. She Came in Through the Bathroom Window
14. Golden Slumbers
15. Carry That Weight
16. The End
17. Her Majesty
===============================
Magical Mystery Tour
Year: 1967
1. Magical Mystery Tour
2. The Fool on the Hill
3. Flying
4. Blue Jay Way
5. Your Mother Should Know
Segmentation fault
j 0
albumname The Beatles White Album
year Year: 1968
j 0songs0 1. Back in the U.S.S.R.
dm.find('=')-1
j 0songs1 2. Dear Prudence
dm.find('=')-1
j 0songs2 3. Glass Onion
dm.find('=')-1
j 0songs3 4. Ob-La-Di, Ob-La-Da
dm.find('=')-1
j 0songs4 5. Wild Honey Pie
dm.find('=')-1
j 0songs5 6. The Continuing Story of Bungalow Bill
dm.find('=')-1
j 0songs6 7. While My Guitar Gently Weeps
dm.find('=')-1
j 0songs7 8. Happiness Is a Warm Gun
dm.find('=')-1
j 0songs8 9. Martha My Dear
dm.find('=')-1
j 0songs9 10. I'm So Tired
dm.find('=')-1
j 0songs10 11. Blackbird
dm.find('=')-1
j 0songs11 12. Piggies
dm.find('=')-1
j 0songs12 13. Rocky Raccoon
dm.find('=')-1
j 0songs13 14. Don't Pass Me By
dm.find('=')-1
j 0songs14 15. Why Don't We Do It in the Road?
dm.find('=')-1
j 0songs15 16. I Will
dm.find('=')-1
j 0songs16 17. Julia
dm.find('=')-1
j 0songs17 18. Birthday
dm.find('=')-1
j 0songs18 19. Yer Blues
dm.find('=')-1
j 0songs19 20. Mother Nature's Son
dm.find('=')-1
j 0songs20 21. Everybody's Got Something to Hide Except Me and My Monkey
dm.find('=')-1
j 0songs21 22. Sexy Sadie
dm.find('=')-1
j 0songs22 23. Helter Skelter
dm.find('=')-1
j 0songs23 24. Long, Long, Long
dm.find('=')-1
j 0songs24 25. Revolution 1
dm.find('=')-1
j 0songs25 26. Honey Pie
dm.find('=')-1
j 0songs26 27. Savoy Truffle
dm.find('=')-1
j 0songs27 28. Cry Baby Cry
dm.find('=')-1
j 0songs28 29. Revolution 9
dm.find('=')-1
j 0songs29 30. Good Night
dm.find('=')-1
j 0songs30 ===============================
dm.find('=')0
j 1
albumname Abbey Road
year Year: 1969
j 1songs0 1. Come Together
dm.find('=')-1
j 1songs1 2. Something
dm.find('=')-1
j 1songs2 3. Maxwell's Silver Hammer
dm.find('=')-1
j 1songs3 4. Oh! Darling
dm.find('=')-1
j 1songs4 5. Octopus's Garden
dm.find('=')-1
j 1songs5 6. I Want You (She's So Heavy)
dm.find('=')-1
j 1songs6 7. Here Comes the Sun
dm.find('=')-1
j 1songs7 8. Because
dm.find('=')-1
j 1songs8 9. You Never Give Me Your Money
dm.find('=')-1
j 1songs9 10. Sun King
dm.find('=')-1
j 1songs10 11. Mean Mr. Mustard
dm.find('=')-1
j 1songs11 12. Polythene Pam
dm.find('=')-1
j 1songs12 13. She Came in Through the Bathroom Window
dm.find('=')-1
j 1songs13 14. Golden Slumbers
dm.find('=')-1
j 1songs14 15. Carry That Weight
dm.find('=')-1
j 1songs15 16. The End
dm.find('=')-1
j 1songs16 17. Her Majesty
dm.find('=')-1
j 1songs17 ===============================
dm.find('=')0
j 2
albumname Magical Mystery Tour
year Year: 1967
j 2songs0 1. Magical Mystery Tour
dm.find('=')-1
j 2songs1 2. The Fool on the Hill
dm.find('=')-1
j 2songs2 3. Flying
dm.find('=')-1
j 2songs3 4. Blue Jay Way
dm.find('=')-1
j 2songs4 5. Your Mother Should Know
dm.find('=')-1
Segmentation fault