linux 下往文件中写入数据代码

linux下往文件中写入数据代码

#include 
#include 

int main()
{
	FILE *pf = fopen("a.txt","w");
	if(pf == NULL)
	{
		printf("open a.txt error\n");
		fclose(pf);
		exit(0);
	}

	for(int i = 0;i <10;i++)
	{
		int x_zara = 10;
		int y_zara = 20;
		fprintf(pf,"x_zara=%d\n,+ y_zara=%d\n",x_zara,y_zara);
	}
	
	fclose(pf);
    pf = NULL;

}

你可能感兴趣的:(linux,linux,write)