well my question is:
if i want to return something from a void how do i do that like:
how?Code:void calculater() { cout << "5+5="; return 10; } int main() { int number=calculater(); cout <<number; getchar(); }
well my question is:
if i want to return something from a void how do i do that like:
how?Code:void calculater() { cout << "5+5="; return 10; } int main() { int number=calculater(); cout <<number; getchar(); }
you don't. you change the return type
how cna you give me a clue?
Code:int calculator() { //... }
You can not do that.
void specifically means no return
if you wan't to return an integer, just declare your function to return an integer:
Also please indent code when you post it.Code:int MyFunction() { cout << "My Statement"; return 10; }
oh thx you, can you return a string to?`;D
You can return a pointer to a char, or you could accept a pointer as an argument and manipulate that string.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
ok well then how do i recieve my things i have returned?
man i maybe like this forum
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
thx ;D. Thread complete and closed
you should really do the tutorials.