系统移植,printf的问题.路过有分
手上有个移植工作   
 在代中使用例如   printf( "%04s ",    "abc ");   
 在Win   AIX   ScoUnix下均输出    "0abc " 
 在红帽Linux下输出    "   abc "   
 请问如何让Linux保持和Win   AIX   ScoUnix系统一致?   
 谢谢!   
 有牛人说   好像gcc有个编译开关的,谁知道? 
------解决方案--------------------只写符合ANSI标准的c代码.
------解决方案--------------------跟编译器应该无关吧。编译器最多给个warning。应该是libc的问题。   
 man printf   
        0      The  value should be zero padded.  For d, i, o, u, x, X, a, A, 
               e, E, f, F, g, and  G  conversions,  the  converted  value  is 
               padded  on  the  left with zeros rather than blanks.  If the 0 
               and - flags both appear, the 0 flag is ignored.  If  a  preci- 
               sion  is  given  with a numeric conversion (d, i, o, u, x, and 
               X), the 0 flag is ignored.  For other conversions, the  behav- 
               ior is undefined.   
 没有对s的支持。最好的方法,别用%0s. 大不了用sprintf打印到buffer里改把改把再打。
------解决方案--------------------http://blog.tianya.cn/blogger/post_show.asp?idWriter=0&Key=0&BlogID=462085&PostID=8363874     
 看看上面这个对你有帮助不?
------解决方案--------------------俺仅仅路过,能不能用最土的预编译解决呀 
 #ifdef  
 #else 
 #endif
------解决方案--------------------应该可以用sprintf到buffer中,再进行输出
------解决方案--------------------你写的复杂了。最简单的方法,就用%s打印到buffer里。strlen比较,前面的补0. 
 还有为什么前面一定要是0, 用 "%4s "前面补空格不一样的马?   
 还有谁说的#ifdef预编译最土? 有什么“不土“的方法可以替代#ifdef?