CHGDIR.CPP
资源名称:C++100.rar [点击查看]
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:1k
源码类别:
Windows编程
开发平台:
Visual C++
- #include<stdio.h>
- #include<direct.h>
- #include<dir.h>
- #include<process.h>
- #include<stdlib.h>
- #include<conio.h>
- void main()
- {
- char PATHNAME[100];
- char NEWPATHNAME[100];
- clrscr();
- if(getcwd(PATHNAME,100)==NULL)
- {
- printf("0:get current directory error!n");
- exit(1);
- }
- printf("The current directory is %sn",PATHNAME);
- printf("nInput the new pathname please:");
- gets(NEWPATHNAME);
- if(chdir(NEWPATHNAME)!=0)
- printf("change current directory error!n");
- printf("nChanging directory SUCCEED!");
- printf("nThe new current directory is %sn",NEWPATHNAME);
- printf("nPress Any Key To EXIT!");
- getch();
- }