Thread: How to use variable in main function that is declare in other function ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    This is what return values and output parameters (i.e., a pointer parameter that points to an object in the caller to which the function can write the result) are for.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #2
    Registered User
    Join Date
    Nov 2019
    Posts
    90
    Quote Originally Posted by laserlight View Post
    This is what return values and output parameters (i.e., a pointer parameter that points to an object in the caller to which the function can write the result) are for.
    I do not understand your answer program should supposed to give result 3 but it's give error so how to get result 3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-11-2015, 05:20 AM
  2. Passing variable from function - main - function
    By ulti-killer in forum C Programming
    Replies: 2
    Last Post: 11-01-2012, 12:14 PM
  3. Replies: 2
    Last Post: 09-19-2012, 11:32 AM
  4. How to declare a global variable in a function?
    By exclusive in forum C Programming
    Replies: 5
    Last Post: 11-06-2011, 04:28 AM
  5. How to declare a global variable in Main()
    By vnrabbit in forum C Programming
    Replies: 2
    Last Post: 06-20-2002, 12:59 PM

Tags for this Thread