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

📄 test7_3.txt

📁 人民邮电出版社的经典著作《Linux下的C编程》配套源码!初学者的必备!共14章
💻 TXT
字号:
#include <sys/types.h>
#include <stdio.h>

int main(void)
{
    	float value, total[10];
    	int count, label;
    	FILE *fp;

    	for(count=0; count<10; count++)
        	total[count]=0;

    	if(!(fp=fopen("test.dat", "r")))
    	{
        	printf("Error in open file.\n");
        	exit(1);
    	}

    	while(!fscanf(fp, "%d%g", &label, &value))
    	{
        	total[label]+=value;
    	}

    	for(count=0; count<10; count++)
    	{
        	printf("%d: %f\n", count, total[count]);
        	return 0;
    	}
}

⌨️ 快捷键说明

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