Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include "txt.h"
  2. using namespace std;
  3.  
  4. void ctxt::scan()
  5. {
  6. for(int i = 0; i < maxLines; ++i)
  7. {
  8. ++m_currentLines;
  9. m_txtList[i] = new char[maxChars];
  10. cin.getline(m_txtList[i], maxChars);
  11. if (*m_txtList[i] == 'q')
  12. break;
  13. }
  14. };
  15.  
  16. void ctxt::print()
  17. {
  18. for(int i = 0; i < maxLines; ++i)
  19. {
  20. cout << "String " << i << ":" << m_txtList[i] << endl;
  21. }
  22. };
  23.  
  24. void ctxt::sort()
  25. {
  26. bool sorted;
  27. char *tempPtrStr[maxChars];
  28.  
  29. do
  30. {
  31. sorted = false;
  32. for (unsigned int i = 0; i < maxLines - 1; ++i)
  33. {
  34. if (strcmp(m_txtList[i], m_txtList[i+1]) > 0)
  35. {
  36. *tempPtrStr = m_txtList[i];
  37. m_txtList[i] = m_txtList[i+1];
  38. m_txtList[i+1] = *tempPtrStr;
  39. sorted = true;
  40. }
  41. }
  42. } while (sorted);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement