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

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

Recommended Answers

All 2 Replies

#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
      printf( "%s\n",buffer );

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

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 : )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.