Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Needs help in function

Posted on 2011-03-17
2
Medium Priority
?
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Starting up a Project
Suggested Courses

618 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