词条 | fread |
释义 | § 解释 函数名: fread 功 能: 从一个流中读数据 用 法: int fread(void *ptr, int size, int nitems, FILE *stream); § 程序例 #include <string.h> #include <stdio.h> int main(void) { FILE *stream; char msg【】 = "this is a test"; char buf【20】; if ((stream = fopen("DUMMY.FIL", "w+")) == NULL) { fprintf(stderr, "Cannot open output file.\"); return 1; } /* write some data to the file */ fwrite(msg, strlen(msg)+1, 1, stream); /* seek to the beginning of the file */ fseek(stream, SEEK_SET, 0); /* read the data and display it */ fread(buf, strlen(msg)+1, 1, stream); printf("%s\", buf); fclose(stream); return 0; } |
随便看 |
百科全书收录594082条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。