打开创建读写文件光标移动:
代码写法一:
#include<stdio.h>
#include<string.h>
int main()
{
//FILE *fopen(const char *path, const char *mode);
FILE *fp;
char *str = "zhongzifeng hen shuai !";
char readBuf[128] = {0};
fp = fopen("./zhong.txt","w+");
//size_t fwrite(const void *ptr, size_t size, size_t nmemb,FILE *stream);
//fwrite(str,sizeof(char),strlen(str),fp);
fwrite(str,sizeof(char)*strlen(str),1,fp);
fseek(fp,0,SEEK_SET);
//size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
//fread(readBuf,sizeof(char),strlen(str),fp);
fread(readBuf,sizeof(char)*strlen(str),1,fp);
printf("read data: %s\n",readBuf);
fclose(fp);
return 0;
}
代码写法二:
#include<stdio.h>
#include<string.h>
int main()
{
//FILE *fopen(co