But if I enter abcf:6252::ffff its not work.
That's understandable. scanf() doesn't know what IPv6 is, you need to figure out how to turn "abcf:6252::ffff" into "abcf:6252:0000:0000:0000:0000:0000:ffff" and write code to do it. That means counting how many fields are missing and filling them in with zeros.