fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. // char str_1[500];
  7. // puts("Input a string: ");
  8. // gets_s(str_1);
  9. char str_1[] = "qwert qwerty qwertyuiop qwer 12345678 qazxswedc";
  10. char str_2[500];
  11. char * str1_end = str_1 + strlen(str_1);
  12. char * cur_str2 = str_2;
  13. char * cur_word = str_1;
  14. int word_length = 0;
  15. for(char *cur_ch = str_1; cur_ch < str1_end; ++cur_ch)
  16. {
  17. if(*cur_ch == ' ')
  18. {
  19. if(word_length > 6)
  20. {
  21. memcpy(cur_str2, cur_word, word_length);
  22. cur_str2 += word_length;
  23. *cur_str2++ = ' ';
  24. }
  25. cur_word += word_length;
  26. ++cur_word;
  27. word_length = 0;
  28. } else {
  29. ++word_length;
  30. }
  31. }
  32. if(word_length > 6)
  33. {
  34. memcpy(cur_str2, cur_word, word_length);
  35. cur_str2 += word_length;
  36. }
  37. if(cur_str2 != str_2)
  38. {
  39. *--cur_str2 = 0;
  40. puts(str_2);
  41. }
  42. }
Success #stdin #stdout 0s 4584KB
stdin
Standard input is empty
stdout
qwertyuiop 12345678 qazxswed