sprintf和printf中有一个%n的标识,可以记录%n之前的字符长度
http://*.com/questions/3401156/what-is-the-use-of-the-n-format-specifier-in-c
#include <stdio.h> int main() { int val; printf("blah %n blah\n", &val); printf("val = %d\n", val); return 0;
}
打印
blah blah val = 5