Im trying to add validation to my loop so that when there is no entry it comes up with an error. However the program justs skips the loop when it should loop again.
I've taken a lot of my code so it's easier o read for you. That's why it may look a little rough.Code:struct music{ char artist[50]; }; int valid = 0; music song[100]; int index; index = 0; do { cout << endl << "Please enter the name of the artist: "; cin.ignore(); cin.getline(song[ index ].artist, 100); cout << song[ index ].artist; if (song[ index ].artist == " ") { cout << "Please enter the name of an artist: "; } else { valid ++; } }while (valid < 1);
It's nothing to do with syntax errors or anything it just skips the validation part.
if (song[ index ].artist == " ")
I've treid so many variations of this, but nothing seems to work.
Anyone help?
Thanks in advance.