To answer your questions:
1. How to daemonize your program: this is a very nice explaination of how do that.
2. Regarding the warning: You are getting that cause the program is trying to assign an address (probably an int, definitely numerical) value to a char type of variable. You can write the code as
and prevent the warning from being thrown.
3. Regarding the output: You are printing an address, which is some random number, as a string. What output are you expecting? Try printing that as an integer.
I think the warning is not because an int type is assigned to a char type ( infact, p when declared as char **p; is definetly not a character variable). The warning comes because of the fact that we are assigning address of a pointer variable to a pointer-to-pointer type variable, and by doing a typecast
u r typecasting a pointer ( &p) to a pointer-to-pointer ...
Infact, this will also work ...
Try doing this on paper with a pen ...
and yes blowtorch, that was a very good link... I too found it useful
The code shown in that link will allow the deamon to remain a session group leader. If a daemon who is a session group leader opens a tty device without specifying the O_NOCTTY flag, the daemon will un-daemonize itself. That is why I prefer: 1.7 How do I get my program to act like a daemon?