0

Hi,

To explain once my app is added to windows path you can simply call it from CMD and you
know how when you run a console it opens up a default folder and you can navigate to a
new on by using cd .. and cd path command. I want to get that path to my app.

Meaning you open CMD, go cd.. cd.. etc to where you want to create a new project say C:\
and once there you just run: create project name and it will create the project in that
directory.

How do i get the path where user using the CMD is at ?

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by nered
1
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>

int main( void )
{
   char* buffer;
   buffer = (char*)malloc(sizeof(char)*MAX_PATH) ;
   // Get the current working directory: 
   if( (buffer = _getcwd( NULL, 0 )) == NULL )
      // code to deal with error
   else
   {
      printf( "%s\n",buffer );
      free(buffer);
   }
}

Adapt it to your needs. But use the getcwd function.

0

Thats a lot that saved me a lot of time i can go and work on the rest of my functions. Um if anyone else tries this just make sure your program name is not conflicting whit another program in ENVIRONMENT VARIABLES -> path

I had to rename mine : )

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.