我有一個結構數組,結構中的一個元素是一個字符串,我需要將這些字符串與12個字符串數組中的其他字符串進行比較。 strcmp似乎不適合我。我知道我需要使用單獨的函數來比較字符串並將值作爲布爾值返回,但無法弄清楚如何使比較函數起作用。比較結構中的字符串和數組中的字符串
的結構
typedef struct{
char *hometeam[Max_number_of_chars], *awayteam[Max_number_of_chars];
int playround, date_day, date_month, date_year,
time_hour, time_minute, home_score, away_score, crowd_thousand,
crowd_hundred;
} match;
串
char *teams[Number_of_teams] = {"AGF","AAB","SDR","RFC",
"EFB","BIF","SIF","OB",
"FCK","FCM", "ACH","FCN"};
,我需要的compare_function
if(compare_names(all_games[i].hometeam, teams[j])==0) {//crazy stuff}
編輯該行的數組:我需要什麼正在功能比較幫助來自* teams [j]的字符串值與來自all_games [i] .hometeam的字符串值。但我不知道如何將struct all_games [i] .hometeam的特定部分傳遞給compare_function,我希望它是char字符串。
請在發佈之前對代碼進行格式化。 – erbdex