Possible Duplicate:
How to compare pointer to strings in C
How to compare the characters in a buffer with a string?
Possible Duplicate:
How to compare pointer to strings in C
How to compare the characters in a buffer with a string?
By buffer, I assume its not NULL terminated. Then you can not use strcmp, instead you can use strncmp.
Assuming, the buffer is an array of characters. You can compare character by character. Example -
char buffer[] = { 'a','b','c' };
char* str = "b";
int i=0;
while( i<3 )
{
if( buffer[i] == *str )
printf("\n Equal \n" );
else
printf("\n Not Equal \n" );
++i;
}
The above code should give you basic idea of how to implement. Results : IdeOne
Things you need to think of to answer the question -
str is "abc"?char* ( i.e., buffer is equal to value pointed by char* ?int strcmp ( const char *s1, const char *s2 );
Try this. It will help you.