Solved

Needs help in function

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now