I am having a problem ending a line after a certain amount of characters. Also I would like not have the second occurrence when I print thing out.

For instance it would show
The first problem

Instead of: KTAKSFJKLAHGLASLDKAJGDKJ

I prefer :
KTAKSFJK
LAHGLASL
DKAJGDKJ

The second problem:

KTTT

K = 1
T = 3
T = 3
T = 3

If anyone knows how to delete the other two I would appreciate.

//Generate Characters
int generateChar( int genChar[], int seed, int numOfChar )
{
    srand(seed);
    for ( int index = 0; index < numOfChar; index++ )
    {
        genChar[index] = (rand() % 25 + 65);
        
        cout << (char)genChar[index];
    }
         cout << endl;
}

//Count numbers
int count( int genChar[], int seed, int numOfChar)
{
    int counter = 0, temp, ascii = 65 ;
    for (int index = 0; index < numOfChar; index++)
    {
        
        temp = genChar[index];
        
        for (int k = 0; k < numOfChar; k++)
        {
           
            if (temp == genChar[k]) { counter++; }
            
        }
        cout << (char)genChar[index] << " = " << counter << endl;
        counter = 0;
        temp = genChar[index];
        
        }  
    
}

1) count the number of characters and when you hit your magic number output a \n
2) call srand() only at the beginning of your program, never in your function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.