-
strchr trouble
Hi all!
This code should work, but it doesn't:
Code:
#include <stdio.h>
int main(void)
{
char *pos;
char buf[100];
FILE *fp;
fp = fopen("text.txt","r");
fgets(buf, 100, fp);
pos = strchr(buf, '~');
if (pos){
printf("Character '~' found at position %d.\n", pos - buf);
}
fclose(fp);
return 0;
}
When I try to compile it I get this:
warning: incompatible implicit declaration of built-in function 'strchr'.
What's wrong with the code?
Thanks in advance for help
-
Perhaps...
Code:
#include <string.h>
-
Have you included string.h header?
-
hurray :) The string header worked
Thanks