美文网首页
Day 1 1-1 Tuesday 2019-01-15

Day 1 1-1 Tuesday 2019-01-15

作者: 顾清_ | 来源:发表于2019-01-16 07:38 被阅读0次

    cs20207

    gather user's first name and last name from a file as a command line argument and print it to the console.

    hi.c

    #include <stdio.h>
    
    int main(int argc, char *argv[]) {
      int c;
      FILE *fp = fopen(argv[1], "r");
      if (fp) {
      printf("Hello world, I am ");
      while((c = getc(fp)) != EOF) putchar(c);
      fclose(fp);
      }
      return 0;
    }
    
    

    name.txt

    Beixi Hao
    
    > gcc -o hi hi.txt
    > ./hi "name.txt"
    Hello world, I am Beixi Hao
    >
    

    相关文章

      网友评论

          本文标题:Day 1 1-1 Tuesday 2019-01-15

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