इसके अलावा "getcwd" कोशिश
#include <unistd.h>
char cwd[100000];
getcwd(cwd, sizeof(cwd));
std::cout << "Absolute path: "<< cwd << "/" << __FILE__ << std::endl;
परिणाम:
Absolute path: /media/setivolkylany/WorkDisk/Programming/Sources/MichailFlenov/main.cpp
परीक्षण वातावरण:
[email protected]$/ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie
[email protected]$/ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
[email protected]$/ g++ --version
g++ (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
स्रोत
2016-12-18 19:40:56
'प्लस वन', आवश्यक नहीं है यह thuogh कोई नुकसान नहीं होगा। विंडोज़ पर –
'GetFullPathName' भी मौजूद नहीं है। 'realpath' के अस्तित्व के पथ की आवश्यकता है। जब आप पथ या फ़ाइल बनाना चाहते हैं तो इस प्रकार का बेकार हो जाता है। – Joakim