I am having a problem with trying to copy a "char array to an int array". I have a code to randomly picked an amount of character and (in progress) print out how many occurrences, even if it's not in there a letter has. For now I'm only doing upper case letter to make sure it works, then I have to add the lower case letter also. I am having problems at line 15. The compiler says "incompatible types in assignment of int to int[100]". Any help is appreciated.
#include <iostream>
#include <cstdlib>
using namespace std;
int getInfo(int& seed, int& numOfChar);
int randomArray(char randomA[], int numOfChar, int seed);
int addLetter(int counter[], char randomA[], int numOfChar);
int main(){
int seed, numOfChar, counter[100] = {0};
char randomA[100];
getInfo(seed, numOfChar);
randomArray(randomA, numOfChar, seed);
counter = (int) randomA;
addLetter(counter, randomA, numOfChar);
for (int i=0; i<numOfChar; i++)
{
if(counter[i]){
cout << randomA[i] << " = " << counter[i];
}
}
system("Pause");
return 0;
}
//Function to Recieve information from user
int getInfo(int& seed, int& numOfChar)
{
cout << "Enter the seed number: ";
cin >> seed;
cout << "\nNumber of characters: ";
cin >> numOfChar;
}
//Function to assign random letter to randomA[] using ASCII code
int randomArray(char randomA[], int numOfChar, int seed)
{
srand(seed);
for(int i=0; i < numOfChar; i++)
{
randomA[i] = rand()% ('Z'-'A') + 'A';
cout << randomA[i];
return randomA[i];
}
}
//Function to add
int addLetter(int counter[], char randomA, int numOfChar)
{
int counter2[100];
for (int j=0; j<100; j++)
{
counter2[j] = counter[j];
}
for (int i=0; i<numOfChar; i++){
if (counter[i] >= '65' || counter[i] <= '90') ++counter2[i];
}
}