cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Main code skips function.
Main code skips function.
Aug 19, 2012 at 7:28pm UTC
josefcool
(1)
Hi im a beginner in programming and c++, and i'm trying to learn to use functions.
I don't get any errors but the main code just seems to skip the function i wrote.
I am using xcode as my compiler.
anybody know why?
code:
#include <iostream>
using namespace std;
void function()
{
cout << "rabarber!!! " << endl;
}
int main()
{
function;
cin.get();
return 0;
}
I haven't found any posts in the forum about this problem.
But if any of you know please link it to me.
Thx
Aug 19, 2012 at 7:33pm UTC
xordux
(26)
First of all learn to put your code in code blocks , second you should call that function ( in main() ) like this :
1
2
3
4
5
6
7
8
9
int
main() { function();
// see this
cin.get();
return
0; }
This should work fine
Last edited on
Aug 19, 2012 at 7:33pm UTC
Topic archived. No new replies allowed.