How to format printf statement better so things always line up

前端 未结 3 675
一生所求
一生所求 2021-01-22 05:53

I have this printf statement:

 printf(\"name: %s\\t\"
        \"args: %s\\t\"
        \"value %d\\t\"
        \"arraysize %d\\t\"
        \"scope %d\\n\",
               


        
3条回答
  •  既然无缘
    2021-01-22 06:38

    Use a specific number for the maximum length of the string, in this case, 12:

    printf("name: %12s", sp->name);
    

提交回复
热议问题