boot2

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

093-string-table.c (526B)


      1 /* Array of pointers to string literals. tcc.c uses this pattern heavily
      2  * (token names, error messages). */
      3 
      4 char *names[] = { "alpha", "beta", "gamma" };
      5 
      6 int strlen_local(char *s) {
      7     int n = 0;
      8     while (*s) { n = n + 1; s = s + 1; }
      9     return n;
     10 }
     11 
     12 int main(int argc, char **argv) {
     13     if (strlen_local(names[0]) != 5) return 1;
     14     if (strlen_local(names[1]) != 4) return 2;
     15     if (strlen_local(names[2]) != 5) return 3;
     16     if (names[0][0] != 'a') return 4;
     17     if (names[2][4] != 'a') return 5;
     18     return 0;
     19 }