Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Borland Vs VC6 & Cout

Status
Not open for further replies.

JohnStep

Programmer
Apr 19, 2000
190
US
I have been using Borlands complier for sometime now. Just recently started using VC6. I have a quick question while using the Cout command with VC6 it gives me errors:

Cout >> "Hi";

but if I use the printf command it works fine. Any ideas what I am doing wring in the IDE so the Cout errors?? And yes I am including <iostream.h>

 
cout is all lower case. That is why it is not working. Also, the line should be
Code:
cout << "Hi";
Notice the "<<" instead of ">>".

Also, if you are including <iostream.h>, you might want to consider changing to <iostream>. The one without the ".h" is new and standard and the one you are using may not work on newer compilers as they come out. If you do use <iostream>, you must put std::cout instead of cout, or as Bones suggested put
Code:
using namespace std;
under the #includes.

Here's an example program:
Code:
#include <iostream>

int main()
{
    std::cout << "This program works!" << std::endl;
    return 0;
}
Or
Code:
#include <iostream>
using namepsace std;

int main()
{
    cout << "This program works!" << endl;
    return 0;
}
 
A small question, is Cout >> "Hi"; a valid expression in BorlandC++?

Ion Filipski
1c.bmp
 
Ion,

Yes you can get the library for cout for Borland c++ builder. So yes it works. I have been trying to take some of my code from BC to VC and even the most mundane code is not compiling with VC++. I even used some of the examples on this thread and they are giving me fits. I'm starting to wonder if my copy of VDS is not complete when it comes to VC++. VB seems to work fine. Thanks to all who has responded!

John Stephens
 
Wow, that's intereting. You might also want to look through the VC++ forum here as well. Once you get comfortable with VC++ let me know which one is better!

-Bones
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top