(%f) 在 C 中是什么意思?

What (%f) means in C?

我知道 %f 表示浮点数,但我不知道括号是否有任何区别。 我有这个:

void print_LIST(LIST L){
    CORD *c;
    while(L != NULL){
        c = L->value;
        printf("%d%d",c->col,c->lin);
        printf("(%f) ",distance(c));
        L = L->next;
    }
    printf("\n");
}

并非格式说明符中的所有内容都是转换说明符(具有特殊含义)。例如:假设 i 的值为 10,以下语句:

 printf ("The value of i is %d", i);

将打印 The value of i is 10,因此字符串的其余部分按原样打印。接下来,在你的情况下

 printf ("(%f)", distance(c));

将打印 distance(c) 函数调用返回的 double 值。假设值为 1.23,它将打印 (1.23)(带括号)。