我写了这个代码:存储从一个字符数组中的值到另一个字符数组
shuffledteamnames[8][80]; // global
winningteamnames[8][80]; // global
int main()
{
if (team1 > team2)
{
cout << shuffledteamnames[index1] << " beat the " << shuffledteamnames[index2] << " " << team1 << "-" << team2 << " in a game 1." << endl;
winningteamnames[WINTEAMcounter] = shuffledteamnames[index1];
}
else if (team1 < team2) // index1 = 0, index2 = 1, WINTEAMcounter = 0
{
cout << shuffledteamnames[index2] << " beat the " << shuffledteamnames[index1] << " " << team1 << "-" << team2 << " in a game 1." << endl;
winningteamnames[WINTEAMcounter] = shuffledteamnames[index2];
}
}
的shuffledteamnames
输出是这样的:
Trojans
Bruins
Bears
Trees
Ducks
Beavers
Huskies
Cougars
我想创建一个竞争支架在那里我将每一轮的获胜者都放入char阵列winningteamnames
。我知道这些是二维字符数组,所以我需要将数据输入到两个参数中,但我不确定如何做到这一点。请让我知道,如果我在任何时候都含糊不清,我非常感谢所有的帮助。
你缺少你的队名数组声明的'char'类型?为什么你不使用'std:string' – Barmar
我们不允许使用字符串或向量 – user3255966
http://en.cppreference.com/w/cpp/string/byte/strcpy –