C++ Function Error

Hi everyone, I'm basic in C++. I'm using Dev-C++. This is my code I'm using but there is an error. Can someone tell me why?

#include <iostream>

// function Demonstrate Function
// prints out a useful messgae
void DemonstrationFunction()
{
std::cout "In Demonstration Function\n";
}

//function main - prints out a message, then
//calls DemonstrationFunction, then prints out
//a second message.
int main()
{
std::cout << "In main\n" ;
DemonstrationFunction();
std::cout << "Back in main\n";
return 0;

It says there is an error with this line.

std::cout "In Demonstration Function\n";

Thanks..

NightJay0044
Last edited on
you forgot your <<
Hey just to remind you that you should write in code form.
Your problem is just syntax. You need << after cout like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>



// function Demonstrate Function 
// prints out a useful messgae
void DemonstrationFunction()
{
	std::cout<<"In Demonstration Function\n";
}

//function main - prints out a message, then
//calls DemonstrationFunction, then prints out
//a second message. 
int main()
{
	std::cout << "In main\n" ; 
	DemonstrationFunction(); 
	std::cout << "Back in main\n"; 
	return 0;
	
	//It says there is an error with this line. 
	
std::cout<<"In Demonstration Function\n";
}
Last edited on
You can use namespace next time which will save you a lot of std:: by:
1
2
#include <iostream>
using namespace std;
Awesome, thank you, :). that's my hugest problem in coding, is syntax...

testing the code
Topic archived. No new replies allowed.