Try this version of flushing the input buffer. This may or may not be the solution in your case, but it is worth a try:
//code code code
cin.ignore( cin.rdbuf()->in_avail() );
getline(cin,str1);
cin.clear();
cin.ignore( cin.rdbuf()->in_avail() );
getline(cin,str2);
cin.clear();
//code code code