# Thread: Illegal operands, why the errors?

1. ## Illegal operands, why the errors?

I am a noob at this quite honestly. I am trying to run a program that I found on the board and I am getting these errors. I am using Microsoft Visual C++.

What is the reason for these errors? and how would they be resolved?

Code:
```h:\c\calendar.c(229) : error C2065: 'cout' : undeclared identifier
h:\c\calendar.c(229) : error C2297: '<<' : illegal, right operand has type 'char [9]'
h:\c\calendar.c(229) : error C2065: 'endl' : undeclared identifier
h:\c\calendar.c(232) : error C2297: '<<' : illegal, right operand has type 'char [17]'
h:\c\calendar.c(233) : error C2065: 'cin' : undeclared identifier
h:\c\calendar.c(233) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
h:\c\calendar.c(236) : warning C4013: 'clrscr' undefined; assuming extern returning int
h:\c\calendar.c(247) : error C2297: '<<' : illegal, right operand has type 'char [9]'
h:\c\calendar.c(251) : error C2297: '<<' : illegal, right operand has type 'char [10]'
h:\c\calendar.c(255) : error C2297: '<<' : illegal, right operand has type 'char [7]'
h:\c\calendar.c(259) : error C2297: '<<' : illegal, right operand has type 'char [7]'
h:\c\calendar.c(263) : error C2297: '<<' : illegal, right operand has type 'char [5]'
h:\c\calendar.c(267) : error C2297: '<<' : illegal, right operand has type 'char [6]'
h:\c\calendar.c(271) : error C2297: '<<' : illegal, right operand has type 'char [6]'
h:\c\calendar.c(275) : error C2297: '<<' : illegal, right operand has type 'char [8]'
h:\c\calendar.c(279) : error C2297: '<<' : illegal, right operand has type 'char [11]'
h:\c\calendar.c(283) : error C2297: '<<' : illegal, right operand has type 'char [9]'
h:\c\calendar.c(287) : error C2297: '<<' : illegal, right operand has type 'char [10]'
h:\c\calendar.c(291) : error C2297: '<<' : illegal, right operand has type 'char [10]'
h:\c\calendar.c(298) : error C2297: '<<' : illegal, right operand has type 'char [38]'
h:\c\calendar.c(299) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
h:\c\calendar.c(305) : error C2297: '<<' : illegal, right operand has type 'char [67]'
h:\c\calendar.c(308) : error C2297: '<<' : illegal, right operand has type 'char [36]'
h:\c\calendar.c(309) : error C2297: '<<' : illegal, right operand has type 'char [27]'```

2. Sounds like you didn't include the appropriate headers for cout.

3. Originally posted by Govtcheez
Sounds like you didn't include the appropriate headers for cout.
What would the solution be? I just wanted to view the program...

I suppose I need the header files right? Where do I get those?

4. #include <iostream>
then the namespace bit:
using namespace std;
or
using std::cout;
or
std::cout <<"Something";

Thread moved to the C++ forum.

5. > I suppose I need the header files right? Where do I get those?

They came with your compiler. At least, they damn well should have.

6. I added iostream. The file needed to be renamed to .cpp

7. You should never include cpp files, only h (header) files.

8. Originally posted by Magos
You should never include cpp files, only h (header) files.
No, I meant I renamed the prog to calendar.cpp and ran it and it worked fine.

It was named calendar.c

9. I think he means his source file. I'm guessing he had it as sdhfksd.c rather than sdhfksd.cpp, thus it used the C compiler not the C++.

10. Ops, my mistake