Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "txt.h"
- using namespace std;
- void ctxt::scan()
- {
- for(int i = 0; i < maxLines; ++i)
- {
- ++m_currentLines;
- m_txtList[i] = new char[maxChars];
- cin.getline(m_txtList[i], maxChars);
- if (*m_txtList[i] == 'q')
- break;
- }
- };
- void ctxt::print()
- {
- for(int i = 0; i < maxLines; ++i)
- {
- cout << "String " << i << ":" << m_txtList[i] << endl;
- }
- };
- void ctxt::sort()
- {
- bool sorted;
- char *tempPtrStr[maxChars];
- do
- {
- sorted = false;
- for (unsigned int i = 0; i < maxLines - 1; ++i)
- {
- if (strcmp(m_txtList[i], m_txtList[i+1]) > 0)
- {
- *tempPtrStr = m_txtList[i];
- m_txtList[i] = m_txtList[i+1];
- m_txtList[i+1] = *tempPtrStr;
- sorted = true;
- }
- }
- } while (sorted);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement