Help.. Class and variables

Hey guys.. I have no clue how to fix this.. so this is a game for 2 players and a bot to guess a game between 1-25 and it's working perfectly as far as I can tell, but the only thing I can't seem to accomplish is to present final results for player1,player2 and the bot to see who wins.

because they just give values zero when out of class, please help if you got the time with explanation so I don't get this problem again. thanks in advance <33

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<iostream>

int num,numbergen,o,c,u;

class player{
public:
int getinput(){
printf("Please enter your number\n");
scanf("%d",&num);

} };

class Game{
public:
void game_description(){
printf("Guess Number Game!!\n\nGuess the number in range 1--->25\n");}

void game_start(){

player player1;
player player2;

int x=0,y=25,range=y-x,r,numbergen,o,c;
srand ( time(NULL) );
numbergen=(rand()%(y+1-x)+x);

for(r=0;r<2;r++){
if (r=1){
printf("Player 1\n");
for(o=1;o<26;o++){
player1.getinput();

if(num>numbergen){
printf("Too big!! Try again, %d chances left. \n",25-o);}
if(num<numbergen){
printf("Too small!! Try again, %d chances left. \n",25-o);}
if(num==numbergen){
printf("Winner!!! you have tried %d Times. \n",o);
break;}}


if (r=2){
numbergen=(rand()%(y+1-x)+x);
printf("Player 2\n");
for(c=1;c<26;c++){
player2.getinput();

if(num>numbergen){
printf("Too big!! Try again, %d chances left. \n",25-c);}
if(num<numbergen){
printf("Too small!! Try again, %d chances left. \n",25-c);}
if(num==numbergen){
printf("Winner!! you have tried %d Times. \n",c);
break;}} }}}
printf("Player1 has tried %d times, Player2 has tried %d times.\n",o,c);

system("pause");}
};
class botpc{
public :
void iplay(){int x=0,y=25,range=y-x,z;
srand ( time(NULL) );
numbergen=(rand()%(y+1-x)+x);

printf("I will play now\n");
for(u=1;u<26;u++){
z=(rand()%(y+1-x)+x);

if(z>numbergen){
printf("%d is too big,trying again..\n",z);}

if(z<numbergen){
printf("%d is too small, trying again..\n",z);}

if(z==numbergen){
printf("OHHH!! %d is the number!!!",z);
printf("I WON IN %d TIMES!!! \n",u);
break;}
}
if(z!=numbergen){printf("Damn I didn't even get the number wtf..");}

system("pause");}
};

class result{
public:
void revealfinal(){
printf("Final results:\n---------\nPlayer1: %d chances used.\nPlayer2: %d chances used.\nBot: %d chances used.\n--------------------\n",o,c,u);
if(o>c){if(o>u){printf("Congratz Player1!! you won!!");}}
if(c>u){if(c>o){printf("Congratz Player2!! you won!!");}}
if(u>c){if(u>o){printf("Bot won!! Bot beat human!! Get rekt!!");}} system("pause");}
};

class beforeclosing{
public:
void attract(){
printf("Name:swag lord\nE-mail:swaggerino@kappatchino.com\nPhone:+321323134537\nPlease visit our website: www.NoobsDevs.com and use the code 'happynoob' to get a discount..\n");system("pause");}
};

int main(){
Game desc;
desc.game_description();
desc.game_start();
botpc bot;
bot.iplay();
result end;
end.revealfinal();
beforeclosing appeal;
appeal.attract();

return 0;
}
because they just give values zero when out of class
What does that mean?

Note that this:

if (r=1){

assigns 1 to r. The comparison operator is ==. I.e. the expression (and all other if(...)) should look like this:

if (r==1){ // Note: ==


Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.