codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#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; }
Private
[
?
]
Run code
Submit