Clare
2013-02-22 08:50:49 UTC
Enter a letter to add: W
Enter the position: 1
Output: WENDY
but the way to do the function is not correctly done as everything is declared globally there is no parameter inside the function. How to correctly correct the function so that value/references could be pass to the main?
Code:
#include
#include
using namespace std;
vector
int i,position;
string letter;
int addLetter()
{
myname.insert(myname.begin() + position-1, letter);
for ( i=0;i
cout<<" "<
cout<
}
int main()
{
myname.push_back("E");
myname.push_back("N");
myname.push_back("D");
myname.push_back("Y");
cout<<"Enter a letter to add: ";
cin>>letter;
cout<<"Enter the position: ";
cin>>position;
addLetter();
system ("pause");
return (0);
}
Thx