是否有一个C宏来产生重复的字符串? [英] Is there a C macro to generate repeat string?
本文介绍了是否有一个C宏来产生重复的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我要产生 ------
,只用 -
,有一个C宏产生重复的字符串?
Suppose I want to generate ------
, with only -
, is there a C macro to generate repeated string ?
推荐答案
使用升压,例如
#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宏来产生重复的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文