fprintf的输出格式控制里有一个可以控制是否输出"+""-"的选项,但是好像不能满足楼主的要求。姑且也写在这里吧,供大家参考。
Minus sign (-)Left-justifies the converted argument in its field%-5.2d
Plus sign (+)Always prints a sign character (+ or -)
%+5.2dSpace characterInserts a space before the value
% 5.2dZero (0)Pads with zeros rather than spaces%05.2d