Ok, i've been messing around with structures and i made one for stats, like in a game. The problem is i'm trying to max the health and mana, so i use health and maxhealth.....
Code:
#include <iostream>
using namespace std;
//Stat structure.////////////////////////////
struct statstr
{
int str;
int agil;
int cons;
int intel;
int wis;
int health;
int maxhealth;
int mana;
int maxmana;
};
//Asigning the structure to a variable.//////
statstr stats;
//Function for writing the stats.////////////
void showstats()
{
cout<<"\nStrength:---"<<stats.str<<"\nAgility:----"<<stats.agil
<<"\nConstition:-"<<stats.cons<<"\nIntellect:--"<<stats.intel
<<"\nWisdom:-----"<<stats.wis<<"\nHealth:-----"<<stats.health<<"/"
<<stats.maxhealth<<"\nMana:-------"<<stats.mana<<"/"<<stats.maxmana<<"\n";
};
int main()
{
//Stat structure values.//
stats.str = 15;
stats.agil = 15;
stats.cons = 15;
stats.intel = 15;
stats.wis = 15;
stats.health = 30;
stats.maxhealth = 30;
stats.mana = 30;
stats.maxmana = 30;
//Testing if everything works//
showstats();
cin.get();
stats.health -= 20;
showstats();
cin.get();
stats.health += 100;
showstats();
cin.get();
//Maxing health////////////////////
if(stats.health > stats.maxhealth)
{
stats.health = stats.maxhealth;
}
}//int main end.
Also i was wondering, where can i learn all the functions in different librarys on my pc...like the iostream, and what they do?
Thanks