C语⾔实现读取⽂件,并统计每个字符出现的个数/*****************
实现读取⽂件,并统计每个字符出现的个数
*****************/
#include <stdio.h>
#include <stdlib.h>
unsigned long file_size;
unsigned int frequency_count[512];
FILE* infilepointer;
void get_frequency_count ()
{
for (unsigned int i = 0; i < file_size; i++)
{
frequency_count[getc(infilepointer)]++;
//getc (infilepointer)从⽂件指针指向的⽂件读⼊⼀个字符
逆光拍摄}
}
bool func(const char* infilename)
{
最聪明的动物if(( infilepointer = fopen(infilename, "rb") ) != NULL)
{
志愿优先fek( infilepointer, 0L, 2);//将⽂件位置指针指向⽂件末尾
file_size = (unsigned long) ftell(infilepointer);
婴儿拉绿屎怎么回事fek( infilepointer, 0L, 0);
get_frequency_count ();
fclo (infilepointer);
return 1;
}
el
{
printf("Error! can't open %s",infilename);
牵挂片尾曲return 0;
}
}
社会团体有哪些
int main()
{
func("C:\\Urs\\Pacer95\\Desktop\\12.txt");
关于读书的诗
printf("%d,",frequency_count[48]);
//这⾥48是0的ascii值,即打印出12.txt⾥0字符的个数,想打印哪个字符,改成对应ascii
凉拌竹笋}
<⾥的内容
统计出0字符的个数,如图