Reputation: 512
I created an array of strings like this:
char header[4][100];
I am then trying to access the first char of the 3rd element in the string array and compare it.
I tried:
strcmp(header[2][0], "/");
Gives me an error of :
comparison between pointer and integer
and also:
const char* tempheader2 = header[2];
const char* firstCharTempHeader = tempheader2[0];
strcmp(firstCharTempHeader , "/");
Gives errors of :
comparison between pointer and integer
initialization makes pointer from integer without a cast
I feel like i am missing something fundamental here...
If this is a duplicate, please mark it. I cant find anything but i might not be searching the right thing
Upvotes: 1
Views: 79
Reputation: 21572
header[2][0]
is a single char
, not a char *
like strcmp
expects.
To compare single characters, just use the regular ==
operator and single quotes:
if(header[2][0] == '/')
Upvotes: 4