What is the error as shown by the compiler?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>

void CountAVD()
{
   int Vowels=0, Alphabets=0, Digits=0; 
   ifstream fil;
   fil.open("Story.txt");
   char ch;
   while(!fil.eof())
   {
	   ch=fil.get();
	   if(isalpha(ch))
	   {
                    Alphabets++;
                       if(strcmpi(ch,"a")==0 || strcmpi(ch,"i")==0||strcmpi(ch,"o")==0|| strcmpi(ch,"e")==0||strcmpi(ch,"u")==0 )
                      Vowels++;
	   }
       else if(isdigit(ch))
		   Digits++;
        	
			
        
   }
        cout<<"Number of Vowels are: "<<Vowels<<endl;
		cout<<"Number of Alphabets are: "<<Alphabets<<endl;
		cout<<"Number of Digits are: "<<Digits<<endl;
}



void main()
{
	   clrscr();
	   CountAVD();
	   getch();
}




Line 19: 
Cannot convert 'int' into 'const char *'
Type mismatch in parameter '__s1' in call the stricmp( const char *, const char *)
Cannot convert 'int' into 'const char *'
Type mismatch in parameter '__s1' in call the stricmp( const char *, const char *)Cannot convert 'int' into 'const char *'
Type mismatch in parameter '__s1' in call the stricmp( const char *, const char *)Cannot convert 'int' into 'const char *'
Type mismatch in parameter '__s1' in call the stricmp( const char *, const char *)Cannot convert 'int' into 'const char *'
Type mismatch in parameter '__s1' in call the stricmp( const char *, const char *)


I am not able to figure out a way to correct these errors. Please help asap.
Also, why does it say stricmp and not strcmpi? stricmp is no function.
Last edited on
i think strcmpi is deprecated.

you could use the std::string compare method maybe?

http://www.cplusplus.com/reference/string/string/compare/
Just another little thing: Try to avoid using <fstream.h> (use its standard equivalent <fstream> instead), and <conio.h> should generally be avoided as well. As well as that, for some reason there is a difference in the error message and the actual function name given (stricmp => strcmpi), though that might be some wierd thing that compiler is doing.
closed account (Dy7SLyTq)
http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/devwin32/strcmpi_xml.html

strcmpi is declared as a macro for stricmp
Anyway you should not use strcmpi here, you are comparing a character, not a string.
if (ch == 'a' || ch == 'A' || ...) is the correct thing to do.
closed account (Dy7SLyTq)
thats not right. i agree he shouldnt use it, but he is in fact calling a string. there is a real difference between "a" and 'a'. "a" is a string literal of one character. 'a' is one character literal and they aren't the same thing. "a" is of type char*, and 'a' is of type char
@modoran is correct... While the "a" (etc.) references are strings, the variable 'ch' is not, it's just a character. Even if he passes &ch, he'll still be in trouble, because 'ch' would not be NULL-terminated. The OP should use character compares, as modoran said.
Topic archived. No new replies allowed.