Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int MYstrlen(char* str)
- {
- int counter = 0;
- while (*str != '\0')
- {
- counter++;
- str++;
- }
- return counter;
- }
- int strCompare(char* first, char* second)
- {
- if (MYstrlen(first) != MYstrlen(second))
- {
- return MYstrlen(first) - MYstrlen(second);
- }
- int counter = 0;
- while (*(first + counter) != '\0')
- {
- if (*(first + counter) != *(second + counter))
- {
- return -1;
- }
- }
- return 0;
- }
- char** splitSentence(char* sentence)
- {
- int numbOfWords = 1;
- int sentSize = MYstrlen(sentence);
- for (int i = 0; i < sentSize; i++)
- {
- if (sentence[i] == ' ')
- {
- numbOfWords++;
- }
- }
- char** returnValue = new char* [numbOfWords];
- for (int i = 0; i < numbOfWords; i++)
- {
- int sizeofword = 0;
- while (sentence[i] != ' ')
- {
- i++;
- sizeofword++;
- }
- returnValue[i] = new char[sizeofword];
- //copy
- }
- }
- void printWords(char* sentence, char ** dictionary)
- {
- }
- int main()
- {
- char* sentence;
- char** dictionary;
- int sentSize, numbOfWords, sizeofWords;
- cin >> sentSize >> numbOfWords >> sizeofWords;
- sentence = new char(sentSize);
- if (!sentence)
- {
- return 0;
- }
- dictionary = new char* [numbOfWords];
- if (!dictionary)
- {
- return 0;
- }
- for (int i = 0; i < numbOfWords; i++)
- {
- dictionary[i] = new char[sizeofWords];
- if (!dictionary[i])
- {
- return 0;
- }
- }
- cin.get();
- cin.getline(sentence, sentSize);
- cout << MYstrlen(sentence);
- printWords(sentence, dictionary);
- for (int i = 0; i < numbOfWords; i++)
- {
- delete[] dictionary[i];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement