Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long getWords(char str[])
- {
- long count = 0;
- long strLength = strLen(str);
- int currentPosition = 0;
- char words[100][100]{ 0 };
- if (strLength == 0)
- return -1;
- for (int i = 0; i <= strLen(str); i++)
- {
- if (str[i] != ' ' && str[i] != '\t' && str[i] != '\0')
- {
- words[count][currentPosition] = str[i];
- currentPosition++;
- }
- else if((str[i] == ' ' || str[i] == '\t' || str[i] == '\0') && str[i - 1] != '\t' && str[i - 1] != ' ')
- {
- count++;
- currentPosition = 0;
- }
- }
- for (int i = 0; i < count; i++)
- {
- std::cout << words[i] << "-";
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement