Solved

Needs help in function

Posted on 2011-03-17
2
396 Views
Last Modified: 2012-05-11
Hi guys: Can any one please help me how to return the value of the response variable outside the getCharacter function ? I try it but it gives syntax error ? Thanks.

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
    {
            getCharacter()
            {
                  char response=' ';
                  cout << "Enter character-->";
                  cin >> response;
                  return response;
            }
      cout << response;
      system("pause");
      return 0;
}

0
Comment
Question by:mustish1
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 35162503
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
char      getCharacter()
            {
                  char response=' ';
                  cout << "Enter character-->";
                  cin >> response;
                  return response;
            }
int main()
    {

      cout <<  getCharacter();
      system("pause");
      return 0;
}
0
 

Author Closing Comment

by:mustish1
ID: 35162511
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question