mahibd
December 19th, 2012, 04:52 PM
Hello Experts,
I need a little help from you??
#include<iostream>
#include<string.h>
using namespace std;
string *playerName()
{
string player[2];
cout<<"\nWelcome to BlackJack Lite!.\n**************************\n";
cout<<"Enter The Name of Player1 :\n ";
getline (cin, player[0]);
cout<<"Enter The Name of Player2 :\n ";
getline (cin, player[1]);
return player;
}
int main()
{
int dealer=0, result[2]={0,0};
string *player=playerName();
cout <<"player 1 is: "<<player[0]<<"player2 is: "<<player[1];
return 0;
}
Warning : address of local variable 'player' returned
I don't understand why this code is not working :confused:
I need a little help from you??
#include<iostream>
#include<string.h>
using namespace std;
string *playerName()
{
string player[2];
cout<<"\nWelcome to BlackJack Lite!.\n**************************\n";
cout<<"Enter The Name of Player1 :\n ";
getline (cin, player[0]);
cout<<"Enter The Name of Player2 :\n ";
getline (cin, player[1]);
return player;
}
int main()
{
int dealer=0, result[2]={0,0};
string *player=playerName();
cout <<"player 1 is: "<<player[0]<<"player2 is: "<<player[1];
return 0;
}
Warning : address of local variable 'player' returned
I don't understand why this code is not working :confused: