星月之求道者 2021-05-31 22:15 采纳率: 0%
浏览 51

如何实现文件的新建、保存、编辑、关闭、退出等操作?

#include "graphics.h"
#include "extgraph.h"
#include "genlib.h"
#include "simpio.h"
#include "random.h"
#include "strlib.h"
#include "conio.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <windows.h>
#include <olectl.h>
#include <stdio.h>
#include <mmsystem.h>
#include <wingdi.h>
#include <ole2.h>
#include <ocidl.h>
#include <winuser.h>
#include<math.h>

struct Data
{
	char variable_name[10];
	double value;
	struct Data *Next_Data;
};
struct Point
{
	double x;
	double y;
	struct Point *Next_Point;
};
typedef struct List
{
	char list_name[10];
	char color[30];
	int ifBar;
	int ifLine;
	int ifPie; 
	struct Data *address;
	struct List *Next_List;
	struct Point *c;
}*LIST;

//将文件数据读入链表 
/*List CreatList()
{
	List head,end,p;
	FILE *fp;
	head=(List)malloc(sizeof(List));
	p=head;
	p->Next_List=NULL;
	
	fp=fopen("test.txt","r");
	
	while(!feof(fp))
	{
		end=(List)malloc(sizeof(List));
		p->Next_List=end;
		p=end;
		p->Next_List=NULL;
		
		fscanf("%s %lf",p->address->variable_name,p->address->value);
	}
	fclose(fp);
	return head;
}*/
//文件保存 
void CreatFile(LIST p)
{
	FILE *fp;LIST q=p;
	fp=fopen("NewFile.txt","wb");
	if(fp!=NULL)
	{
		while(q)
		{
			
			fprintf(fp,"%s %s %d %d %d",q->list_name,q->color,q->ifBar,q->ifLine,q->ifPie);
			while(q->c)
			{
				fprintf(fp,"%lf %lf",q->c->x,q->c->y);
				q->c=q->c->Next_Point; 
			}
		}
	}
	fclose(fp);
}

//文件
List  OpenFile(FILE *fp)
{
	List head,end,p;
	head=(List)malloc(sizeof(List));
	p=head;
	p->Next_List=NULL;
	return head;
} 

void Main()
{
	List p;
	if(/*新建*/)
	{
		p=CreatList();
		
	}
	
}

利用给定的libgraphics库制作一个简易的数据可视化小程序,如何实现将绘制好的图表通过文件保存,对统计图表修改后将数据更新至文件。

  • 写回答

2条回答 默认 最新

  • 关注

    要使用图形库graphics的各种画图函数,实现可视化

    评论

报告相同问题?

悬赏问题

  • ¥15 python怎么在已有视频文件后添加新帧
  • ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵