二十五岁时我们都一样愚蠢、多愁善感,喜欢故弄玄虚,可如果不那样的话,五十岁时也就不会如此明智。
标题:C库函数 - fread()
C库函数 - fread()
#include <stdio.h> #include <string.h> int main () { FILE *fp; char c[] = "this is codingdict"; char buffer[100]; /* Open file for both reading and writing */ fp = fopen("file.txt", "w+"); /* Write data to the file */ fwrite(c, strlen(c) + 1, 1, fp); /* Seek to the beginning of the file */ fseek(fp, 0, SEEK_SET); /* Read and display data */ fread(buffer, strlen(c)+1, 1, fp); printf("%s\n", buffer); fclose(fp); return(0); }