Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ice-T

Help, very simple C++ code wont work on MSVC.

This topic is 5551 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can somebody tell why this wont work? #include <iostream> int main() { char r = ''r''; cout << r; return(0); } It tells me that cout is unrecognized. Prior to this, it said that and couldn''t be found. If so, where can I get these files? It''s not on my MSVC CD.

Share this post


Link to post
Share on other sites
Advertisement

#include <iostream>

int main()
{
char r = 'r';
std::cout << r;
return(0);
}


Bakingsoda36's method works, too.

[edited by - smart_idiot on August 9, 2003 12:53:46 AM]

Share this post


Link to post
Share on other sites
Thanks for the help but that''s not it. I keep getting this error:

c:\program files\microsoft visual studio\vc98\include\xlocale(11) : fatal error C1083: Cannot open include file: ''stdexcept'': No such file or directory
Error executing cl.exe.

Where can I get the "stdexcept"? I can''t seem to get it off my MSVC CD.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You might want to try putting .h after the file''s name. If namespaces don''t work....

ex.
#include <iostream>
using namespace std;

... this may work out better for you...

#include <iostream.h>
// using namespace std; <-- don''t need this with *.h

Also, if you are working with Visual Studio (esp. 6.0), make sure your project is a Win32 Console Application, not a Win32 Application.

I hope this works out for you.
~Belgarion

Share this post


Link to post
Share on other sites
quote:
Original post by RhoneRanger
char r="r";

should also work.

No it shouldn't. Don't be a dumbass; that's an implicit conversion from "const char*" to "char", which doesn't work in any context. How could that possibly help anything?

[edited by - zealouselixir on August 10, 2003 1:35:36 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I believe that trying to use:

char r = "r";

as opposed to:

char r = ''r'';

will result in an error.

The "r" is a null terminating string, so there is a hidden element, the ''\0'' character. A char type will only accept a single char type, not two. If you turn r into:

char r[2];

Then you might be able to work around that. If I am mistaken, please tell me.

~Belgarion

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!