User talk:Concernedresident/assquotesource
From RationalWiki
assuming you're not going to have any words over LINELENGTH characters, I think this would work:
void wrapPrint (string assquote) { int i = LINELENGTH; if (assquote.length() > LINELENGTH) { for(;assquote[i] != ' ' && i > 0; i--); cout << assquote.substr(0,i) << endl; wrapPrint(assquote.substr(++i, assquote.length()-i)); } else cout << assquote << endl; }
— Sincerely, Neveruse / Talk / Block 17:55, 13 May 2010 (UTC)
Alternatively, with the same assumption:
string wrapString (string assquote) { int i = LINELENGTH; if(assquote.length() > LINELENGTH) while(assquote[i] != ' ' && i > 0) i--; return assquote.substr(0,i-(assquote.length()>LINELENGTH)) + '\n' + (assquote.length() > i ? wrapString(assquote.substr(++i, assquote.length()-i)) : ""); }
— Sincerely, Neveruse / Talk / Block 18:11, 13 May 2010 (UTC)