Code:
#include <stdio.h>
#include <stdlib.h>
int main(void){
char buf[81];
int x;
scanf("%s", buf);
x = strlen( buf );
printf("length: %d", x) ;
return 0;
}
in the above code i got this warning: incompatible implicit declaration of built-in function ‘strlen’
does anyone know why?
the next code is almost the same but it has a small change in the green marks.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void){
char buf[] = "I am a programer";
int x;
x = strlen(buf);
printf("length: %d", x);
return 0;
}
My question is the following: when i use the 1st program typing "This is C book" returns lenght: 4 but in the second instead of "I am a programmer" if i write "This is C book" it will return lenght: 14
. Why?
i' ll be glad if anyone could help me! thanks in advance...