Ok the thing I searched into google brought up a ton of nonsense. I want to use variables from a function in main and (more important) variables from main in a function. I am already using file I/o as a loophole but I want an easier way.
PS How do I combine strings? Again my loophole is file io but it takes so long to type. The one I found on google gave me a buch of 'error strut instant to char crap as I am using this to get a filename has to be in c style or else the compiler gives me grief.
Zssffssz
-4
Junior Poster
Recommended Answers
Jump to PostOk the thing I searched into google brought up a ton of nonsense. I want to use variables from a function in main and (more important) variables from main in a function.
Declare the variables globally.i.e before main()
#include<iostream> using namespace std; //declare variables here int main(){}
Jump to PostOk the thing I searched into google brought up a ton of nonsense.
Lack of understnding does not make the information nonsense...
I want to use variables from a function in main...
Pass the values back to main() when the function returns.
... and (more important) variables from main in …
All 5 Replies
tkud
0
Posting Whiz in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
gerard4143
371
Nearly a Posting Maven
Zssffssz
-4
Junior Poster
gerard4143
371
Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.