Did you write the code? What part of it you do and do not understand?
If you are referring to this line:
if(str[offset - 1] == '\n' && str[offset - 2] == '\r') break;
what it does is it breaks out of the while loop when it sees a string terminated by a DOS-style line break (i.e. a newline character '\n' plus a carriage return character '\r'). This is bad practice, by the way, because this won't work with *NIX line breaks (a '\n' by itself). What OS is your computer running?