“192.168.0.1”分割为4部分,存到
4个字符串中。
thx

解决方案 »

  1.   

    没有split函数,不知怎么动手,因为
    ip是可以变得,比如有时候变成192。168。11。111长度也就不同了,立即给分
      

  2.   

    char val[4];
    DWORD ip;
    ip=inet_addr("192.168.0.1");
    memcpy(val,&ip,4);
      

  3.   

    error C2065: 'inet_addr' : undeclared identifier
     error C2664: 'memcpy' : cannot convert parameter 2 from 'unsigned long' to 'const void *'
      

  4.   

    use strtok function/* Compile options needed: none
    */ #include <string.h>
    #include <stdio.h>char *string = "a string,of ,,tokens";
    char *token;void main(void)
    {
            token = strtok(string," ,"); /*There are two delimiters here*/ 
            while (token != NULL){
                    printf("The token is:  %s\n", token);
                    token = strtok(NULL," ,");
            }

    The output of this program is as follows: 
    The token is: a
    The token is: string
    The token is: of
    The token is: tokens 
      

  5.   

    thx all,but how can I get the socket.h???
    the inet_addr doesn't work when I link it,