Website Design United States, Website Design California, Website Designing United States, Website Designing California

Get Current Working Directory - C++

The GetCurrentPath function is a C++ function to return the current working directory. Generally this is the application path, but it can be different if using a shortcut with a different "Start in" path.

#include <direct.h> // for getcwd
#include <stdlib.h> // for MAX_PATH
#include <iostream.h> // for cout and cin

// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}

void main()
{

// _MAX_PATH is the maximum length allowed for a path
char CurrentPath[_MAX_PATH];
// use the function to get the path
GetCurrentPath(CurrentPath);

// display the path for demo purposes only
char temp[_MAX_PATH];
cout << CurrentPath << endl;
cout << "Press Enter to continue";
cin.getline(temp,_MAX_PATH);
}

 
WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com