Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

strings and loops?

$
0
0
hi. im trying to make a loop that will end when the user types in 8 numbers for the telephone number. a function will read in the telephone number itself and the loop will call that function. the function has to send back the string either using a reference parameter or by returning a value. im not sure how to do this but this is what i have so far.
here is the main program:
int main()
{
    string telephone;
    
    for (int x = 0; x < telephone.length(); x++) {
   readoriginalnumber(); 
        
    }


here is the function:
string readoriginalnumber () {
    string telephone;
    
    cout<< "Enter your telephone number" << endl; 
    cin>> telephone;  
    cout<< endl << telephone << " is your original number" << endl;
    return telephone; 
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>