我需要在循环的每次迭代中形成一个字符串,其中包含循环索引i
:
for(i=0;i<100;i++) {
// Shown in java-like code which I need working in c!
String prefix = "pre_";
String suffix = "_suff";
// This is the string I need formed:
// e.g. "pre_3_suff"
String result = prefix + i + suffix;
}
我try 使用strcat
和itoa
的各种组合,但运气不佳.