From: Derek C. <de...@ci...> - 2009-02-03 23:55:29
|
The language works you know, it's been around a bit! You need to put a^b in parentheses because of operator precedence. int main() { char a = 'A'; char b = 'Z'; cout << static_cast<char>(a ^ b) << endl; system("pause"); } Omit the cast if you want the output as a number rather than a character. This is because the default type of any expression involving chars is actually int. On Tue, Feb 3, 2009 at 11:33 PM, Heedle Blambeedle <hee...@gm...> wrote: > XOR is this character: ^. It does not seem to operate in DevC++. When I > attempt to compile this: > > #include <iostream> > using namespace std; > #define PI 3.14159 > #define NEWLINE '\n' > int main () > { > char a; > char b; > cout << a ^ b << endl; > system("pause"); > } > > I get this error: > > invalid operands of types `char' and `<unknown type>' to binary `operator<<' > > Is there a solution to this? > > Heedle. > ------------------------------------------------------------------------------ > Create and Deploy Rich Internet Apps outside the browser with > Adobe(R)AIR(TM) > software. With Adobe AIR, Ajax developers can use existing skills and code > to > build responsive, highly engaging applications that combine the power of > local > resources and data with the reach of the web. Download the Adobe AIR SDK and > Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > |