I am trying to replace all characters in text with char
[*]. It only displays the first four. If i type anything after 6 digits it displays 5
[*]. Could anyone help me?. Look at the function twoplayer(w). Thats the one i am concerned with now
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
#define infile "music.txt"
char oneplayer(string z);
float twoplayer(float w);
float chances(int y);
int main()
{
int x,y;
string z;
cout << "Welcome to hangman Game" << endl;
cout << "For one player type 1, two player type 2" << endl;
cin >> x;
switch(x)
{
case 1:
cout << "Entering 1 player mode" << endl << endl;
chances(y);
oneplayer(z);
break;
case 2:
cout << "Entering 2 player mode" << endl;
chances(y);
twoplayer(x);
cout << endl;
break;
default: cout << "This isn't no nintendo Wii, we use flash drives";
return 0;
}
}
char oneplayer(string z)
{
ifstream fin;
ofstream fout;
fin.open(infile);
if(fin.fail())
{
cout << "What" << endl;
}
cout << "one" << endl;
cin >> z;
}
float twoplayer(float w)
{
string p;
string x;
int charcount;
x = '*';
int z;
do
{
cout << "Two player mode" << endl << endl;
cout << "Enter a word two be guessed" << endl;
cin >> p;
cout << p.length() << endl;
for(int i = 0; i < p.length(); ++i)
{
cout << p.replace(i, i, x) << endl;
}
cin>> z;
}while (z!= z);
}