c语言V6++求解?

Python025

c语言V6++求解?,第1张

首先,uintr这个变量应该是float型的,这句话的意思是输出以下内容:

      intr initial statue=x.xxxV

其中x.xxx是uintr中保存的数,连小数点占5个字符位置,小数点后3位做四舍五入处理,另外如果数据加上小数点加上小数点后面的3位实际占用超过5个字符,则以实际占用为准

比如:uintr=5.3047362,则输出为:        intr initial statue=5.305V

#include <stdio.h>

int main(void)

{

    char s1[50],s2[50]={0}

    int n

    scanf("%d",&n)

    while(n--)

    {

        int f

        char *p=s1, *q=s2

        int t

        scanf("%s",s1)

        while(p<s1+40)

        {

            sscanf(p, "%x",&t)

            if(t==0 && f==0)

            {

                f=1

            }

            else

            {

                sprintf(q, "%X", t)

                while(*q)q++

            }

            

            *q++=':'

            p+=5

        }

        *(q-1)=0

        puts(s2)

    }

    return 0

}

Linux本身已经有ipv6合法性的判断宏

#include <netinet/in.h>

int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *aptr)

int IN6_IS_ADDR_LOOPBACK(const struct in6_addr *aptr)

int IN6_IS_ADDR_MULTICAST(const struct in6_addr *aptr)

int IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *aptr)

int IN6_IS_ADDR_SITELOCAL(const struct in6_addr *aptr)

int IN6_IS_ADDR_V4MAPPED(const struct in6_addr *aptr)

int IN6_IS_ADDR_V4COMPAT(const struct in6_addr *aptr)

// 还有几个多播宏

int IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *aptr)

int IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *aptr)

int IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *aptr)

int IN6_IS_ADDR_MC_ORGLOCAL(const struct in6_addr *aptr)

int IN6_IS_ADDR_MC_GLOBAL(const struct in6_addr *aptr)

返回0代表成功,返回非零值代表ipv6地址为非指定类型的的地址。

希望有帮助