Dezzy Dezzy - 2 months ago 7x
C Question

First character of pointer

I have a question regarding char pointers.

I am reading a file in C, using

. This is a short overview so you can understand what I would like to do:

char configline[configmax_len + 1]; //configmax_len is the max value I need
while(fgets(configline, sizeof(configline), config){ //config is the file
char *configvalue = strtok(configline, " ");
if (configvalue[0] == "#"){


char * configvalue
is a pointer to the current line being read. What I would like to check is if the first character of the line is a "#".

However when I do the if statement:
if (configvalue[0] == "#")
, the compiler throws an error:
comparison between pointer and integer

How could I check if the first character of the string a pointer is pointing to is a certain value?

Tom Tom

try using

if (configvalue[0] == '#'){

this should compile nicely