1 #include <stdio.h>
2 #include <string.h>
3
4 size_t my_strlen(const char *s)
5 {
6 size_t i;
7
8 i = 0;
9 while (s[i])
10 i++;
11 return (i);
12 }
13
14 int main()
15 {
16 char s[10] = "bonjour";
17 char s2[10] = "bonjour";
18
19 printf("%d\n", strlen(s2));
20 printf("%d\n", my_strlen(s));
21 return (0);
22 }
When i test this code at my school on a Imac it works fine, but on my macbook Pro i get this message:
test.c:19:17: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
printf("%d\n", strlen(s2));
~~ ^~~~~~~~~~
%lu
test.c:20:17: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
printf("%d\n", my_strlen(s));
~~ ^~~~~~~~~~~~
%zu
when i changed it , it's fine, but why i get this message on my personnal computer ? (2 GHz Intel Core i7,4 Go 1333 MHz DDR3,Intel HD Graphics 3000 384 Mo)