This question already has answers here:
C preprocessor macro for returning a string repeated a certain number of times
(4个答案)
3年前关闭。
假设我想只用
(4个答案)
3年前关闭。
假设我想只用
------
生成-
,是否有一个C宏来生成重复的字符串? 最佳答案
使用提升,例如
#include <stdio.h>
#include <boost/preprocessor/repetition/repeat.hpp>
#define Fold(z, n, text) text
#define STRREP(str, n) BOOST_PP_REPEAT(n, Fold, str)
int main(){
printf("%s\n", STRREP("-", 6));
return 0;
}
关于c++ - 有C巨集来产生重复字串吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11532883/