Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

String input, pointer to int

Name: Anonymous 2006-04-09 1:19

#include "stdio.h"
#include "string.h"

int _tmain(int argc, _TCHAR* argv[])
{
    char str[80];
    int oct[4];
    int i;
    printf("Enter your IP address:");
    scanf ("%s",str);
    int * pch;
    pch = strtok (str,".");
    for(i=0;i<5;i++)
    {
     printf ("%s\n",pch);
     oct[i]= (pch&);
     pch = strtok (NULL,".");
    }
    system("PAUSE");
    return 0;
}

How would I get this to work? I have been playing with C++, have a program working, and I need a way to break up an IP address and store each octet in an array of integers.  Maybe one of you elite programmers can help a n00b. Thanks.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List