我有以下两个数组:
const char[3] *Letters= {"one", "two", "three"}
const char[5] *Numbers= {"1", "2", "3","4", "5"}
如何打印键值对,例如:
("one" "1"), ("one", "2"), ("one", "3")......("two", "1"), ("two", "2")...
我正在尝试使用 for 循环来执行此操作:
for(i=0;i<3; i++){
for(i=0;i<5; i++){
printf("%s %s \n", Letters[i],Numbers[i]);
}
}
问题是我上面的方法不行
最佳答案
只需为内部 for
循环语句使用单独的变量。常见的是j
。
关于c - 组合两个数组的键值对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26534837/