
20.08.2010, 19:27
|
|
Участник форума
Регистрация: 28.03.2007
Сообщений: 252
Провел на форуме: 469020
Репутация:
63
|
|
Школьных знаний программирования мне хватило, чтобы за 2 минуты написать на СИ сепаратор:
Исходник:
Код:
Code:
#include
#include
#include
#include
#include
#include
int read (FILE* source)
{
char word[1024]="", str[1024];
if (!fgets(str, 1023, source)) return 0;
if (str[0]=='1')
{
FILE* file = fopen ("1.txt", "a");
fputs (str, file);
fclose (file);
}
if (str[0]=='2')
{
FILE* file = fopen ("2.txt", "a");
fputs (str, file);
fclose (file);
}
if (str[0]=='3')
{
FILE* file = fopen ("3.txt", "a");
fputs (str, file);
fclose (file);
}
if (str[0]=='4')
{
FILE* file = fopen ("4.txt", "a");
fputs (str, file);
fclose (file);
}
if (str[0]=='5')
{
FILE* file = fopen ("5.txt", "a");
fputs (str, file);
fclose (file);
}
if (str[0]=='6')
{
FILE* file = fopen ("6.txt", "a");
fputs (str, file);
fclose (file);
}
return 1;
}
void main()
{
FILE* source = fopen ("source.txt", "r");
while (read (source));
fclose (source);
}
Файл расфасовывает данные из файла source.txt в 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt. Разумеется все файлы должны быть в одной папке. Скачать
|
|
|