boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

023-strings.c (414B)


      1 /* tests/cc-e2e/23-strings.c — string literal walked via *s, s = s + 1.
      2  * Split from 01-kitchen-sink. */
      3 
      4 int test_strings(void) {
      5     char *s = "world";
      6     int sum = 0;
      7     while (*s) {
      8         sum = sum + *s;
      9         s = s + 1;
     10     }
     11     return sum;                     /* w+o+r+l+d = 119+111+114+108+100 = 552 */
     12 }
     13 
     14 int main(int argc, char **argv) {
     15     if (test_strings() != 552) return 1;
     16     return 0;
     17 }