⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fscanf_fprintf.cpp

📁 本程序介绍了如何用C语言快速读写磁盘文件。
💻 CPP
字号:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/********************************************************
	fprintf(文件指针,格式字符串,输出表列);
	fscanf(文件指针,格式字符串,输入表列);
*********************************************************/
void fscanf_fprintf_test()
{

	char str_1[10]="abc";
	char str_2[10]="def";
	int i=1000;
	FILE *fp;

	fp = fopen( "E:\\C++_sample\\File_operating\\File_testing.txt", "r+" );
	if(fp == NULL)
	{
		printf("cannot open the file\n");
		exit(0);
	}

	printf("\nsrc:\n%s,%s,%d\n",str_1,str_2,i);

	fprintf(fp,"%s\n%s\n%d",str_1,str_2,i);
	rewind(fp); // equal to fseek(fp,0L,SEEK_SET);
	fscanf(fp,"%s%s%d",str_1,str_2,&i); 

	printf("\ndes:\n%s,%s,%d\n",str_1,str_2,i);

	return;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -