阅读背景:

C - 在命令行中使用尖括号

来源:互联网 

At the moment I have this code:

目前我有这个代码:

int main(int argc,char* argv[]) {
    FILE * fp;
    char * line = NULL;
    size_t len = 0;
    ssize_t read;

    char * txtfile = argv[1];

    fp = fopen(txtfile, "r");
    if (fp == NULL)
        exit(EXIT_FAILURE);

    while ((read = getline(&line, &len, fp)) != -1) {
        printf("Retrieved line of length %zu :\n", read);
        printf("%s", line);
    }

    fclose(fp);
    if (line)
    free(line);
    exit(EXIT_SUCCESS);

    return 0;
}
i



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: