Help, very simple C++ code wont work on MSVC.
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.
#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]
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.
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.
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
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
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]
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
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
quote:Original post by Anonymous Poster
You might want to try putting .h after the file''s name. If namespaces don''t work....
No, don''t do this.
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement