cin >> str;
In the above example the extraction operation stops when any of the non-whitespace characters are encountered in input stream (stdin).
While accepting SrNo we are entering enter sign. This sign remains in the input stream and interferes with the working of the next input function getline().
cin.ignore(100,'\n'); extracts maximum 100 characters or until \n' is encountered. this ensures that the input stream contains no characters even the enter sign.
cin.getline(t_str,100,'\n'); extracts maximum 99 characters or till delimiting character '\n' is encountered in stdin and assignes the same to the character array. Thus making it possible for us to read string containing embedded spaces