编程学习网为您整理以下代码实例,主要实现:C语言库fread()函数,希望可以帮到各位朋友。
#include <stdio.h>
#include <string.h>
int main () {
file *fp;
char c[] = "this is yiibai";
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);
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!