What's Here?
- Members: 148,919
- Replies: 505,077
- Topics: 79,552
- Snippets: 2,662
- Tutorials: 705
- Total Online: 2,505
- Members: 105
- Guests: 2,400
|
Getting the current directory. TAKEN FROM BORLAND C++ HELP
|
Submitted By: born2c0de
|
|
Rating:
 
|
|
Views: 48,160 |
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
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|