fork download
  1. #include <cstdio>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. const string str("atgctgttg");
  8. const int n = 5; // Assumed positive number smaller than str.size()
  9. const int n1 = n - 1;
  10.  
  11. for (auto i = str.cbegin(); i != str.cend() - n1; ++i) {
  12. printf("%.*s\n", n, &*i);
  13. }
  14. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
atgct
tgctg
gctgt
ctgtt
tgttg