hello.c

#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #define MAX_LEN 80 /* int main(int argc, char *argv[]){ char word[MAX_LEN] = "../test.binvox"; printf("You entered: %s\n", word); return 0; } */ int main(void) { FILE * fp; char * line = NULL; size_t len = 0; ssize_t read; fp = fopen("../test.binvox", "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); }
// Created by yuqiong on 3/1/19.
// toy file to test c-style I/O.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.