Basically, I have to show each word with their count but repeated words show up again in my program.
How do I remove them by using loops or should I use 2d arrays to store both the word and count?
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <cstring>
#include <conio.h>
#include <time.h>
using namespace std;
char* getstring();
void xyz(char*);
void tokenizing(char*);
int main()
{
    char* pa = getstring();
    xyz(pa);
    tokenizing(pa);
    _getch();
}
char* getstring()
{
    static char pa[100];
    cout << "Enter a paragraph: " << endl;
    cin.getline(pa, 1000, '#');
    return pa;
}
void xyz(char* pa)
{
    cout << pa << endl;
}
void tokenizing(char* pa)
{
    char sepa[] = " ,.\n\t";
    char* token;
    char* nexttoken;
    int size = strlen(pa);
    token = strtok_s(pa, sepa, &nexttoken);
    while (token != NULL) {
        int wordcount = 0;
        if (token != NULL) {
            int sizex = strlen(token);
            //char** fin;
            int j;
            for (int i = 0; i <= size; i++) {
                for (j = 0; j < sizex; j++) {
                    if (pa[i + j] != token[j]) {
                        break;
                    }
                }
                if (j == sizex) {
                    wordcount++;
                }
            }
            //for (int w = 0; w < size; w++)
            //fin[w] =  token;
            //cout << fin[w];
            cout << token;
            cout << " " << wordcount << "\n";
        }
        token = strtok_s(NULL, sepa, &nexttoken);
    }
}
This is the output I get:
I want to show, for example, the word "i" once with its count of 5, and then not show it again.

 
     
     
     
     
    