i am trying to review what C++ stuff i have learned last year before high school starts, but the code i am writing does not run properly after i compile it.
the code compiles
the code does not execute. the code does not execute after Recruit() runs C_Name() to get a string.
i have removed all my badly spelled cout text for you)
// first text based RPG
// Test
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
int Start();
void Wait();
string Recruit();
string AskText(string prompt);
string C_Name();
int main()
{
Start();
return 0;
}
string C_Name() //i think the problem is here
{
string name ="l";
int characters;
characters = name.size();
while(characters != 0)
{
if(characters <= 1)
{
cin>>name;
}
if(characters > 1)
{
return name;
}
else
{
characters = -1;
}
}
}
string AskText(string prompt)
{
string text;
cout<<prompt;
cin>>text;
return text;
}
/**this does not work but i will solve by myself later
*void Wait()
*{
* char responce='a';
*
* while((responce != 'y') || (responce != 'Y'))
* {
* cout<<endl;
* cout<<"do you wish to continue? (y/n)";
* cin>>responce;
* cout<<endl;
* }
*}
*/
string Recruit()
{
char answer = 'n';
string Name;
cout<<"-"<<endl
<<"-"<<endl
<<"-"<<endl;
Name = C_Name();
while((answer !='y') || (answer != 'Y'))
{
cout<<"- "<<Name<<"? (y/n)"<<endl;
cin>>answer;
if(answer == 'y' || answer == 'Y')
{
return Name;
}
else
{
cout<<"-"<<endl;
Name = C_Name();
}
}
}
int Start()
{
cout<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl
<<"-"<<endl;
Recruit();
return 0;
}