小编Sim*_*one的帖子

sscanf 和 scanset 停止读取十六进制数字

我尝试验证 UUID v4。我尝试使用 sscanf 执行此操作,如果可以使用 sscanf 完全读取 UUID(= 读取的字符总数 - 36),我认为这是一个正确的 UUID。到目前为止我的代码:

#include <stdio.h>

int main()
{
    char uuid[ 37 ] = "da4dd6a0-5d4c-4dc6-a5e3-559a89aff639";
    int a = 0, b = 0, c = 0, d = 0, e = 0, g = 0;
    long long int f = 0;

    printf( "uuid >%s<, variables read: %d \n", uuid, sscanf( uuid, "%8x-%4x-4%3x-%1x%3x-%12llx%n", &a, &b, &c, &d, &e, &f, &g ) );
    printf( " a - %x, b - %x,  c - %x,  d …
Run Code Online (Sandbox Code Playgroud)

c uuid scanf

5
推荐指数
1
解决办法
469
查看次数

标签 统计

c ×1

scanf ×1

uuid ×1