Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
28
Добавлен:
17.04.2013
Размер:
837 б
Скачать
#include<dir.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main(int pnum, char *par[])
{
	clrscr();

	char *str;
	int res, n=0, i, f=1, t=0;
	struct ffblk found, *files;

	if (pnum<=1)
		par[1]="";

	strcat(par[1],"*.*");

	res=findfirst(par[1],&found,0);
	while(!res)
	{
		n++;
		res=findnext(&found);
	}

	if (n>0)
	{
		files=new ffblk[n];

		n=0;
		res=findfirst(par[1],&found,0);
		while(!res)
		{
			files[n]=found;
			n++;
			res=findnext(&found);
		}
	}

	while (f)
	{
		f=0;
		for (i=0;i<=n-2;i++)
		{
			if (strcmp(files[i].ff_name,files[i+1].ff_name)>0)
			{
				found=files[i];
				files[i]=files[i+1];
				files[i+1]=found;
				f=1;
			}
		}
	}

	for (i=0;i<=n-1;i++)
		printf("%s\n",files[i].ff_name);
	printf("Num of files: %d\n",n);

	getch();
}
Соседние файлы в папке Lab6