求助关于c语言 文件读写的问题

来源:百度知道 编辑:UC知道 时间:2024/09/22 10:38:35
要求1.txt文件中有若干文件名,通过c语言实现文件名排序,排序后的文件输入到2.txt中。
希望高手帮忙,谢谢
文件名按字典顺序排序,例如1.txt中为:abc.txt feos.doc cjet.txt 要求输出2.txt中为abc.txt cjet.txt feos.doc
希望高手帮忙,谢谢

提个问题也不提清楚点… 按什么顺序排序?字母顺序?
这涉及到文件读写和排序算法两个东西,你多给点信息好不好?
顺给你这段代码,原创的。统计一篇文章里字母出现个数的信息。
#include <stdio.h>
// To summarize frequency of each character in Source.txt
int main()
{
float count[26];
memset(count, 0, sizeof(count)); // Initialize array to 0;
int c, i, t = 0;
FILE *Source;
Source = fopen("C:/Documents and Settings/TangKe/My Documents/NetBeansProjects/Frequency/Source.txt","r");
if (Source == NULL)
perror("Error in opening file!");
else {
do {
c = fgetc (Source);
for(i = 0; i <= 25; i++){
if (c == 65 + i || (c == 97 + i)) { count[i]++; t += 1;}
}
} while (c != EOF);
fclose (Source);
}
for(i = 0; i <= 25; i++){
printf(" %c(%c) appeared %5.0f times which contributed %9f%% to total length;