I wrote a piece of code to find out the ipaddress of my linux machine. It works well when I compile it and run it in /tmp directory. But when I convert it to a binary using makefile, put it in /usr/sbin directory and run it, Im getting the following error.
Below is my code. Im using this peice of code in one of my helper processes for squid proxy. I have set the permissions for the myip.txt file in /usr/sbin/myip.txt using chmod 777 /usr/sbin/myip.txt.
Im still wondering why Im getting this permission denied error.
Below is my code.
#include<iostream>
#include<fstream>
#include<stdlib.h>
using namespace std;