scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0169-string.c (389B)


      1 char s0[] = "foo";
      2 char s1[7] = "foo";
      3 char s2[2] = "foo";
      4 char s3[] = {"foo"};
      5 char *p = "foo";
      6 
      7 int
      8 cmp(char *s1, char *s2)
      9 {
     10 	while (*s1 && *s1++ != *s2++)
     11 		;
     12 	return *s1;
     13 }
     14 
     15 int
     16 main()
     17 {
     18 	if (sizeof(s0) != 4 || cmp(s0, "foo"))
     19 		return 1;
     20 	if (cmp(s1, "foo"))
     21 		return 1;
     22 	if (s2[0] != 'f' || s2[1] != 'o')
     23 		return 1;
     24 	if (sizeof(s3) != 4 || cmp(s3, "foo"))
     25 		return 1;
     26 	return 0;
     27 }