%S7
这样格式的模板,7表示长度,仍是变量。知道需求后,第一步就是用snprintf()
去拼字符串了,可能没搜到合适的关键字,一开始没找到合适的方法。html
make后是没问题,第2天提交代码后cppcheck,出现了 warning: format not a string literal, argument types not checked。 这是字符串变量与字符串常量的问题数组
char s[10] = {0}; char sValue[16] = {0}; snprintf(s,sizeof(s),"%%0%dd",iNum); // iNum是变量 snprintf(sValue, sizeof(sValue), s, "业务代码值"); // s就至关于格式化输出