69,382
社区成员
发帖
与我相关
我的任务
分享
// GETCWD.C
/* This program places the name of the current directory in the
* buffer array, then displays the name of the current directory
* on the screen. Specifying a length of _MAX_PATH leaves room
* for the longest legal path name.
*/
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
char buffer[_MAX_PATH];
/* Get the current working directory: */
if( _getcwd( buffer, _MAX_PATH ) == NULL )
perror( "_getcwd error" );
else
printf( "%s\n", buffer );
}
/* CHGDIR.C: This program uses the _chdir function to verify
* that a given directory exists.
*/
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
void main( int argc, char *argv[] )
{
if( _chdir( argv[1] ) )
printf( "Unable to locate the directory: %s\n", argv[1] );
else
system( "dir *.wri");
}