#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    29
    Rep Power
    0

    Need help for a problem


    I am trying to get the IP address from the getenv but I am geting the out put as null for the REMOTE_ADDR and for HTTP_COOKIE. Bellow is my code..

    Code:
    #include <stdio.h>
    #include<conio.h>
    #include <windows.h>
    #include <stdlib.h>
    
    int main()
    {
    	char *lp_ip	;
    	char *lp_cookie;
    	char *path;
    	char *lib;
    
    	lp_ip			= getenv ("REMOTE_ADDR");
    	lp_cookie		= getenv ("HTTP_COOKIE");	
    	path			= getenv ("PATH");
    	lib				= getenv ("LIB");
    
    	printf("%s\n",lp_ip);
    	printf("%s\n",lp_cookie);
    	printf("%s\n",path);
    	printf("%s\n",lib);
    	return 0;
    
    }
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    Are you writing a Common Gateway Interface(CGI) program?

    The CGI wrapper provides you with a whole bunch of environment variables.

    If you're not, then you have a fundamental mis-understanding of the problem (and we've no idea what that problem is).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    29
    Rep Power
    0
    Yes, I am writing the CGI program. rather there is reference code but when I am trying to do a test program(the one above ) its not giving me the IP.

IMN logo majestic logo threadwatch logo seochat tools logo