#include<iostream>
#include<fstream>
#include<string>
using namespace std;
//Place the function declaration (prototype) below this line
string function(int n);
void main(void)
{
string name;
ofstream fout("D:\\1\\names.dat"); //change the path of the file if necessary
for(int i=1;i<=5;i++)
{
function(i);
// insert a statement below to call the function you write and keep the returned string
// in the string name
fout<<name<<endl;
}
fout.close();
// insert several statements to read the 5 names you have just inputted
// display them on screen, each in one line
ifstream fin("D:\\1\\names.dat");
getline(fin,name);
cout<<name<<endl;
fin.close();
}
string function(int n){
string name;
cout<<endl<<"This function is called "<<n<<" times"<<endl;
cout<<"Please input 5 person's full name(Give name + space + family name):"<<endl;
getline(cin,name);
name.substr();
}
string function(int n){
string name;
cout<<endl<<"This function is called "<<n<<" times"<<endl;
cout<<"Please input 5 person's full name(Give name + space + family name):"<<endl;
getline(cin,name);
name.substr();
}
如何返回name 这个string 阿????