#include<iostream.h>
struct PlayerData{ int strength; int charisma; int intelligence; int dexterity; };
void PrintData(PlayerData); file://函数声明用结构体类型 void PrintData(const char *lineToPrint);
int main() { PlayerData myPlayerData={24,29,12,2};
const char *title="\nTHE WARTH OF ZALTHAR"; const char *copyrightLine="Copyright 2005,[Your Name Here]";
PrintData(title); PrintData(copyrightLine);
PrintData(myPlayerData); //函数调用时用结构体变量
return 0; }
void PrintData(PlayerData myPlayerData) file://函数定义时用结构体类型和它的变量 { cout<<"\nStrength: "<<myPlayerData.strength<<'\n'; cout<<"Charisma: "<<myPlayerData.charisma<<'\n'; cout<<"Dexterity: "<<myPlayerData.dexterity<<'\n'; cout<<"Intelligence: "<<myPlayerData.intelligence<<'\n'; }
void PrintData(const char *lineToPrint) { cout<<lineToPrint<<"\n"; } 上面的程序我已经修改了你的错误,能运行 你就错函数方面,你不信,自己试了就知道