Solved

Needs help in function

Posted on 2011-03-17
2
397 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 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

705 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