howdy
i'm trying to figure iut how to return a string from a function. have i missed something in the following code???
----------code---------------
#include <iostream>
#include <string>
using namespace std;
string stringy ()
{
string string1;
cout<<"Enter a string"<<endl;
getline(cin, string1);
return string1;
}
int main ()
{
int number;
string string1;
stringy();
cout<<"How many times?\n";
cin>> number;
for (int index = 0; index < number; index++)
{
cout<<index <<">--->>>"<< string1 <<"<<<--<"<< index<<endl;
}
return 0;
}
i wrote this in emacs and am running rh 2.4.7?
it seems to compile allright but when run it will not place the entered string (string1) into the line between the index numbers.
thanks from a sel teaching newbie
M.R.