Problem with structure function
hi, it's me again. This time I am having problems writing a function that alters the data of the structure type. this is what i have can anyone tell me why it doesn't work. Thanks
Code:
#include <iostream.h>
#include <string>
using namespace std;
struct individualtype ///////includes monsters and characters
{
string mainname;
string name;
int level;
float maxhp;
float hp;
float maxmp;
float mp;
float luck;
float vitality;
float strength;
float accuracy;
float speed;
float defense;
float blackmagic;
float whitemagic;
float greenmagic;
float skillpoints;
};
individualtype adventurer;
individualtype monster;
int setpoints(int level, individualtype x)
{
//if level one
x.maxhp=10;
x.maxmp=6;
x.luck=2;
x.vitality=2;
x.strength=7;
x.accuracy=5;
x.speed=5;
x.defense=7;
x.blackmagic=2;
x.whitemagic=2;
x.greenmagic=2;
x.skillpoints=0;
////if past level one
for(int b=1;b<x.level;b++)
{
x.maxhp=x.maxhp*3/2;
x.maxmp=x.maxmp*4/3;
x.luck=x.luck*5/4;
x.vitality=x.vitality*5/4;
x.strength=x.strength*9/7;
x.accuracy=x.accuracy*6/5;
x.speed=x.speed*6/5;
x.defense=x.defense*9/7;
x.blackmagic=x.blackmagic*5/4;
x.whitemagic=x.whitemagic*5/4;
x.greenmagic=x.greenmagic*5/4;
}
return 0;
}
int main();
{
adventurer.level=1;
monster.level=1;
cout<<"Hello"<<endl;
setpoints(adventurer.level, adventurer);
setpoints(monster.level, monster);
cout<<monster.maxhp<<endl;
return 0;
}
all the values remain 0 they do not change when i try to display them. I think it should work, someone please correct my reasoning I think i may be off.