ok i have this code .. i just want to change one thing, instead of entering a string .. i'd like to have this be the default string "ABcaBadd*eekjdfefdeg,TTew44Tt"
Code:
#include <iostream>
#include <cctype>
using namespace std;
//counts how many each character shows
void count(const char myStr[]){
for (int x = 97; x < 123; x++){
int count1 = 0;
for (int i =0; myStr[i] != '\0' ; i++){
if (myStr[i] == (char)x){
count1++;
}
}
if (count1 != 0)
cout << (char)x << " appears " << count1 << " times\n";
}
}
int main(){
char phrase1[500];
cout << "What is your String?\n";
cin.getline (phrase1, 500);
const int x=500;
char myarray[x];
int c = 0;
//takes each char from the string and check to see if it is both
// not a space and is a alphabetical char
for(int i = 0; phrase1[i] != '\0'; i++){
if (isalpha(phrase1[i])){
myarray[c]=tolower(phrase1[i]);
c++;
}
}
//reassigns null terminator to the end of the array
myarray[c]= '\0';
count(myarray);
return 0;
}