Совет 5 (Паскаль)
Программа 7_08.bas
SHELL "dir *.bas" END
Программа 7_08.с
#include <stdio.h>
#include <conio.h>
#include <dir.h>
#include <dos.h>
main() {
struct ffblk sr;
int k,nf=0;
long lf=0;
struct tim
{
unsigned sec:5;
unsigned min:6;
unsigned hour:5;
};
struct dat {
unsigned day:5;
unsigned month:4;
unsigned year:7;
};
union {struct tim a;
unsigned b;}u;
union {struct dat c;
unsigned d; }v;
clrscr();
printf("Имя файла Длина Дата Время");
k=findfirst("*.c",&sr,FA_ARCH);
while (k==0) {
u.b=sr.ff_ftime; v.d=sr.ff_fdate; nf++;
lf+= sr.ff_fsize;
printf("\n%12s %61d ",sr.ff_name,sr.ff_fsize) ;
printf(" %02d/%02d/%4d ",v.c.day,v.c.month,1980+v.c.year);
printf(" %02d:%02d",u.a.hour, u.a.min);
k=findnext(Ssr); }
printf("\n%d файлов занимают %ld байт",nf,If);
getch(); }
Программа 7_08.pas
program dir;
uses Crt,Dos; var
dt:DateTime;
sr:SearchRec;
const
nf:integer=0;
If:longint=0;
function Zero(k:byte):string;
var
s: string;
begin
Str(k,s);
if k>9 then Zero:=s else Zero:= '0 '+s; end;
begin clrscr;
writeln('Имя файла Длина Дата Врекя');
FindFirst('*.pas',AnyFile,sr);
while DosError=0 do
begin with sr,dt do
begin inc(nf);
If:=lf+Size;
UnpackTime(Time, dt);
write (Name:12, ' ',Size:6, ' ');
write(Zero(Day), '/',Zero(Month), '/',Year:4, ' ');
writeln(Zero(Hour), ': ',Zero(Min), ': ',Zero (Sec)); end;
FindNext(sr); end;
writeln(nf, ' файлов занимают ',1f, ' байт');