What's Here?
- Members: 300,293
- Replies: 825,468
- Topics: 137,351
- Snippets: 4,417
- Tutorials: 1,147
- Total Online: 2,131
- Members: 117
- Guests: 2,014
|
Getting the current directory. TAKEN FROM BORLAND C++ HELP
|
Submitted By: born2c0de
|
|
Rating:
 
|
|
Views: 71,480 |
Language: C++
|
|
Last Modified: March 2, 2005 |
Snippet
// The Code is Borland's, I just modified it
// to make it Standard C++
#include <direct.h> // for getcwd
#include <stdlib.h>// for MAX_PATH
#include <iostream> // for cout and cin
using namespace std;
// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}
int 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);
return 0;
}
Copy & Paste
|
|
|
|