0

I have an executable file mzApp (compiled c program by gcc compiler) in a directory /root/home/mzApplication.

I run this file from another directory i.e. /root/home/check and from this location, I issued the following command to run the application ./root/home/mzApplication/mzApp.

Now I want to get both of the following paths in my c application

  1. Where exe file is located i.e. /root/home/mzApplication
  2. From where this application is called i.e. /root/home/check

Please suggest an efficient way to do this!

Umair
  • 336
  • 1
  • 16
  • Have a look [here](https://stackoverflow.com/questions/933850/how-do-i-find-the-location-of-the-executable-in-c) – izlin Aug 30 '18 at 12:27
  • Thanks, @izlin. This link has a way to get exe path. But also want to get a path from where the application is invoked. – Umair Aug 30 '18 at 12:31
  • I can't find a dupe, but you'd use `getcwd`. Also, I recommend not asking multiple different questions per post. – melpomene Aug 30 '18 at 12:36

0 Answers0