美文网首页
数组和大小

数组和大小

作者: 淡蓝色的叹息 | 来源:发表于2018-06-20 10:34 被阅读0次

    for循环和字符串数组


    include <stdio.h>

    int main(int argc, char *argv[])
    {
    int i =0;

      // go through each string in argv
      // why am i skipping argv[0]?
     for (i = 1; i < argc; i++) {
     printf("arg %d: %s\n", i, argv[i]);
    

    }

      //let's make our own array of strings
      char *states[] = {"california","oregon", "washington","texas"};
    
      int num_states = 4;
      
      for (i = 0; i < num_states; i++) {
      printf("state %d: %s\n", i, states[i]);
      }
      return 0;
    

    }
    }

    相关文章

      网友评论

          本文标题:数组和大小

          本文链接:https://www.haomeiwen.com/subject/gldtyftx.html