fork download
  1. #include <cstring>
  2. #include <iostream>
  3.  
  4. void print(const char* str, unsigned width)
  5. {
  6. const char* line = str;
  7. const char* end = line + std::strlen(line);
  8. const char* letter = line;
  9.  
  10. while ( line < end )
  11. {
  12. while ((letter - line) < width && letter != end)
  13. std::cout << *letter++;
  14.  
  15. std::cout << '\n';
  16. line += width;
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. const char* s = "Supercalifragilisticexpialidocious";
  23.  
  24. print(s, 2);
  25. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Su
pe
rc
al
if
ra
gi
li
st
ic
ex
pi
al
id
oc
io
us