我有一个字符串数组,我只想要用户需要的元素。字符串数组如下:
const char* string2[]={"•-","-•••", "-•-•","-••", "•", "••-•","--•","••••","••","•---","-•-","•-••",
"--","-•","---","•-•","--•-","•-•","•••","-","••-","•••-","•--","-••-",
"-•--","--••","•----","••---","•••--","••••-","•••••","-••••","--•••","---••",
"----•","-----"," "};
我创建了一个逻辑,我可以从中获取用户所需的字符串数组,但是我无法获得正确的输出。问题是例如我输入Hello,我得到的数字如下:[8 5 12 12 15]
现在我希望我的输出为string2 [8]:••,string2 [5]:•• - •等等。
我需要做些什么更改才能让它在此工作?
for(a[i]=0;a[i]<length;a[i++]){
printf("%s\t",string2[i]);
}
我试图让它发挥作用,但我无法取悦。
答案 0 :(得分:0)
您可能需要以下内容:
for(int i = 0; i < length; i++)
printf("%s\t", string2[a[i]]);