CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    30

    Avoiding hard coding of IP Address

    Hi,
    I wanted to avoid the hard coding of IP Address in my implementation using standard C. Instead I want to pass it so that I can connect to different remote hosts. Any example of how I can do this.

    Regards

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Avoiding hard coding of IP Address

    Quote Originally Posted by [email protected] View Post
    Hi,
    I wanted to avoid the hard coding of IP Address in my implementation using standard C. Instead I want to pass it so that I can connect to different remote hosts. Any example of how I can do this.

    Regards
    On the command line:
    Code:
    myApp.exe 128.146.12.10
    Viggy

  3. #3
    Join Date
    Jan 2011
    Posts
    5

    Re: Avoiding hard coding of IP Address

    #include <stdio.h>

    int main(int argc, char *argv[])

    {
    if (argc != 2)
    {
    printf("\n Wrong arguments.. Enter ip address.");
    }

    char *printerIP;
    printerIP = argv[1];

    printf("\n printerIP is %s ",printerIP);

    getchar();
    return 0 ;

    }

  4. #4
    Join Date
    Aug 2008
    Posts
    112

    Re: Avoiding hard coding of IP Address

    Quote Originally Posted by [email protected] View Post
    Hi,
    I wanted to avoid the hard coding of IP Address in my implementation using standard C. Instead I want to pass it so that I can connect to different remote hosts. Any example of how I can do this.

    Regards
    What if you have a long list of remote IP addreses you want to connect ? I agree hardcoding takes time and mind to deal with. What application are you working on, actually ? Because I think sometimes it depends on the actual modules you try to implement too so you need to be a little choosey for which method is more appropriate.
    hi,,,

  5. #5
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Avoiding hard coding of IP Address

    There's no need for hardcoding
    1. Enter on the command line
    2. Enter into a list box (GUI)
    3. Enter into a side file

    These are just a few alternatives.

    Viggy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured