ok so what im trying to do is to read some text from a file. Put them into an array. And count the number of characters in the text file using pointers to access the array. However, when i compile i get an error for this line check = isalpha('*text'); It says the character constant is too long for its type. Im kinda stuck at this point and not sure how to solve it.
const int SIZE = 500;
char fileName[20];
char text[SIZE];
int main()
{
cout << "Enter filename: " << endl;
cin >> fileName;
fstream infile(fileName, ios::in);
infile.getline(text, SIZE);
int charNum = countChar(text);
cout << "Number of characters: " << charNum << endl;
infile.close();
return 0;
}
int countChar(char* text)
{
int count1 = 0;
bool check;
while (*text != '\0')
{
check = isalpha('*text');
if(check == true)
count1++;
text++;
}
return count1;
}