Hai everyone,
I have one doubt... Can u please clarify this...
If i put
char a[10]="hai-hello"

if(strcmp(a[4],'-')==0)


then it will displays an error
strcmp' : cannot convert parameter 1 from 'char' to 'const char *'


Wat is the reason for this?
Can anybody tell me

Recommended Answers

All 3 Replies

just look at the suntax of stcmp() and u will be able to understand.
int strcmp ( const char * str1, const char * str2 );

it take address of the char, not the char.

the function is strcmp. you are comparing a character and not a string.

You only need to go:

if( a[4] == '-') because the == operator can compare characters.
also in the string:
char a[10]="hai-hello"
it will return false because the - is at position a[3] not position a[4].

If you are using strcmp you can compare strings (notice double quotes).

K thanks for ur suggestion

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.