I have a program defined in a certain directory A, and a shortcut to it in another directory B, and I have B added to PATH. In a different directory C I am running cmd.exe and am executing this program with the command progname.lnk arg1 arg2
. My understanding is that the "current working directory" in this situation is C, but when I use _getcwd (see below) to obtain the current working directory I get directory A, the place where the program is kept.
#include <iostream>
#include <direct.h>
#define GCWD _getcwd
int main() {
char cwd[256];
GCWD(cwd, 256);
std::cout << cwd << std::endl;
}
I compiled and ran this program with the command mwe.lnk
. This program is stored in A, has a shortcut to it in B, and I ran it from C, just like my actual program.
This code is informed by computinglife's answer to a related question, which is the same technique used here.
Is my understanding of what a "current working directory" is correct? It seems to agree with the first paragraph of computinglife's answer, so what am I doing wrong?