📄 chap16.lst
字号:
listing 1
chdir("C:\\WP\\FORMLET");
listing 2
_chdrive(3); /* switch to drive C */
listing 3
#include <dos.h>
#include <stdio.h>
int main(void)
{
struct find_t f;
register int done;
done = _dos_findfirst("*.c", _A_NORMAL, &f);
while(!done) {
printf("%s %ld\n", f.name, f.size);
done = _dos_findnext(&f);
}
return 0;
}
listing 4
#include <stdio.h>
#include <dos.h>
#include <dir.h>
int main(void)
{
struct ffblk f;
register int done;
done = findfirst("*.cpp", &f, 0);
while(!done) {
printf("%s %ld\n", f.ff_name, f.ff_fsize);
done = findnext(&f);
}
return 0;
}
listing 5
#include <stdio.h>
#include <dir.h>
int main(void)
{
char path[MAXPATH];
fnmerge(path, "C:", "", "TEST", ".C");
printf(path);
return 0;
}
listing 6
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char fpath[_MAX_PATH];
_fullpath(fpath, "\\INCLUDE", _MAX_PATH);
printf("Full path: %s\n", fpath);
return 0;
}
listing 7
#include <stdio.h>
#include <dir.h>
int main(void)
{
char dir[MAXDIR];
getcurdir(0, dir);
printf("Current directory is %s", dir);
return 0;
}
listing 8
#include <stdio.h>
#include <dir.h>
int main(void)
{
char dir[MAXDIR];
getcwd(dir, MAXDIR);
printf("Current directory is %s", dir);
return 0;
}
listing 9
#include <stdio.h>
#include <direct.h>
int main(void)
{
char path[MAXPATH];
_getdcwd(4, path, MAXPATH);
printf("Current directory of drive D is %s\n", path);
return 0;
}
listing 10
#include <stdio.h>
#include <dir.h>
int main(void)
{
printf("Current drive is %c", getdisk()+'A');
return 0;
}
listing 11
printf("Current drive is %d.", _getdrive());
listing 12
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char fpath[_MAX_PATH];
char fname[_MAX_FNAME];
char dir[_MAX_DIR];
char drive[_MAX_DRIVE];
char ext[_MAX_EXT];
_makepath(fpath, "B:", "MYDIR", "MYFILE", "DAT");
printf("%s\n", fpath);
_splitpath(fpath, drive, dir, fname, ext);
printf("%s %s %s %s\n", drive, dir, fname, ext);
return 0;
}
listing 13
#include <dir.h>
int main(void)
{
mkdir("FORMLET");
return 0;
}
listing 14
#include <stdio.h>
#include <dir.h>
char fname[7] = "XXXXXX";
int main(void)
{
mktemp(fname);
printf(fname);
return 0;
}
listing 15
#include <stdio.h>
#include <dir.h>
int main(void)
{
if(!rmdir("FORMLET")) printf("FORMLET removed.\n");
return 0;
}
listing 16
#include <stdio.h>
#include <dir.h>
int main(void)
{
printf(searchpath("BCC32.EXE"));
return 0;
}
listing 17
#include <stdio.h>
#include <dir.h>
int main(void)
{
printf("%d drives", setdisk(0));
return 0;
}
listing 18
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char fname[_MAX_FNAME];
char dir[_MAX_DIR];
char drive[_MAX_DRIVE];
char ext[_MAX_EXT];
_splitpath("C:\\MYDIR\\MYFILE.DAT", drive, dir, fname, ext);
printf("%s %s %s %s\n", drive, dir, fname, ext);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -