[ create a new paste ] login | about

Link: http://codepad.org/JHc84ZJp    [ raw code | output | fork ]

C, pasted on May 19:
#include <stdio.h>
#include <string.h>

int main(void)
  {
  char str[50] = "sufeiuA215.10.30.40";
  char ip[50], *s;
  unsigned q, i;

  if(!(s=strchr(str,'A')))
    *ip=0;
  else
    for(++s,q=0,i=0; s[q]; ++q)
      if(s[q]=='.' && ++i==3)
        {
        while(s[++q]>='0' && s[q]<='9');
        strncpy(ip, s, q), ip[q]=0;
        break;
        }

  puts(ip);
  return 0;
  }


Output:
1
215.10.30.40


Create a new paste based on this one


Comments: