How to repeat a char using printf?

前端 未结 12 1210
难免孤独
难免孤独 2020-11-28 03:24

I\'d like to do something like printf(\"?\", count, char) to repeat a character count times.

What is the right format-string to accomplish

12条回答
  •  没有蜡笔的小新
    2020-11-28 04:23

    You can use the following technique:

    printf("%.*s", 5, "=================");
    

    This will print "=====" It works for me on Visual Studio, no reason it shouldn't work on all C compilers.

提交回复
热议问题