djelad1

Untitled

Dec 5th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. char text1[LINES2][MAX_LETTERS2];
  2. char text2[LINES2][MAX_LETTERS2];
  3. char text3[LINES2][18];
  4. int i = 0, lettersCounter = 0, sumText1 = 0, sumText2 = 0, sumTwoAndOne = 0;
  5. cout << "Please fill text 1 with " << LINES2 << " lines and max " << MAX_LETTERS2 << " letters" << endl;
  6. for (i = 0; i <= LINES2; i++)
  7. cin.getline(text1[i], MAX_LETTERS2);
  8. cout << "Please fill text 2 with " << LINES2 << " lines and max " << MAX_LETTERS2 << " letters" << endl;
  9. for (i = 1; i <= LINES2; i++)
  10. cin.getline(text2[i], MAX_LETTERS2);
  11. for (i = 1; i <= LINES2; i++, sumTwoAndOne = 0)
  12. {
  13. sumText1 = strlen(text1[i]);
  14. sumText2 = strlen(text2[i]);
  15. sumTwoAndOne = sumText1 + sumText2;
  16. if (sumTwoAndOne <= MAX_LETTERS2)
  17. {
  18. strcpy_s(text3[i], text1[i]);
  19. strcat_s(text3[i], text2[i]);
  20. }
  21. else if (sumTwoAndOne > MAX_LETTERS2)
  22. text3[i] == " ";
  23. }
  24. cout << "text 3 is : \n";
  25. for (i = 1; i <= LINES2; i++)
  26. cout << text3[i] << endl;
Advertisement
Add Comment
Please, Sign In to add comment