Thread: Again with another Problem

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    11

    Again with another Problem

    Alright, I have just now found I have a problem with char and int. If I wanted to enter an IP like 127.0.0.1 as Int it would read it as a charecter, if i had char it would read as an Integer. How do I use both at the same time

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    huh?

    You need to provide details. And I'd suggest asking this question in the networking forum.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    I guess you could store the IP in a string...if that's what you're asking.
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    You could create a class that would allow you to quickly retrieve any aspect of it with a function call.

    Code:
    class IPaddr
    {
    public:
    int num[4];
    char *str();
    char *str(int nIndex);
    };
    
    char * IPaddr::str()
    {
    char *temp=new char[32];
    itoa(num[0],temp,10);
    //etc
    }
    
    char *IPaddr::str(int nIndex)
    {
    char *temp=new char[4];
    itoa(num[nIndex],temp,10);
    return temp;
    }
    Although that may be overkill. I just love classes.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM