Hi, I've been trying to get a simple fuction to work for ages, i understand what functions are and what they do i just dont know how to make the give and return values. I've read the chapter on functions over and over plus some tuts on the net but i still dont get it.
I know this is a bit much to ask but could someone please explain exactly how fuctions give and take data.
Heres a peice of something i'm trying to do
this code gives me these errorsCode:#include <iostream> int half(int a); int main() { int a; std::cout<<"Enter a number: "; std::cin>>a; half(int a); std::cout<<"The number is now " <<a; return 0; } inline int half(int a) { a=-5; return a; }
error C2144: syntax error : missing ')' before type 'int'
error C2660: 'half' : function does not take 0 parameters
error C2059: syntax error : ')'
i've tried just about everything i can think of but i just dont get it
Thanks