473,410 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

> is printing as 62 and < is printing as 60

why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?

Jul 22 '05 #1
13 1230
JustSomeGuy wrote:
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?

Something like the following code gives you that output?
#include <iostream>

int main()
{
std::cout << '<';
}

--
Sumit Rajan <su*********@gmail.com>
Jul 22 '05 #2
'<' is character code 62, and '>' is character code 60 - the stream operator
just sees them as ints - cout << "<" would work.

ad

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?

Jul 22 '05 #3
JustSomeGuy wrote in news:JcJsd.415656$Pl.248656@pd7tw1no in comp.lang.c++:
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?


It maybe that you are runing your compiler in some non-standard
mode and the type of '<' is not char. There isn't AFAICT any
flag you can set for std::ostream's that causes this to happen.

#include <iostream>

int main()
{
std::cout << '<' << (int)'<' << '\n';
}

The above outputs "<60\n" for me.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #4

"adbarnet" <ad******@barnet.com> wrote in message
news:41********@127.0.0.1...
'<' is character code 62, and '>' is character code 60 - the stream operator just sees them as ints - cout << "<" would work.

ad

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?



Sorry I obviously haven't posted all the code here..
but when I try
cout << "<"
it prints out the address of the "<" string.


Jul 22 '05 #5
JustSomeGuy wrote in news:hOJsd.434542$nl.182628@pd7tw3no in
comp.lang.c++:

"adbarnet" <ad******@barnet.com> wrote in message
news:41********@127.0.0.1...
'<' is character code 62, and '>' is character code 60 - the stream

operator
just sees them as ints - cout << "<" would work.

ad

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
> why would cout << '<' print 62
> and cout << '>' print 60
> Is there some flag that I have clobbered?
>
>
>



Sorry I obviously haven't posted all the code here..
but when I try
cout << "<"
it prints out the address of the "<" string.


Are you including <ostream> ?

#include <iostream> /* for std::cout */
#include <ostream> /* for the << operators & std::endl */

int main()
{
std::cout << '<' << "<" << std::endl;
}

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #6

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?

I"m new here and this may be an obvious statement, but what it looks like
it's priniting is the ascii values for "<" and ">"
Jul 22 '05 #7

"Jeremy A. Smith" <je*******@comcast.net> wrote in message
news:lu********************@comcast.com...

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?

I"m new here and this may be an obvious statement, but what it looks like
it's priniting is the ascii values for "<" and ">"


Yes exactly.. it is treating all 'x' or '<' or what ever is single quoated
as a
integer rather than a character... it is therefor printing the ascii code
for the character.

Jul 22 '05 #8

JustSomeGuy wrote:
"adbarnet" <ad******@barnet.com> wrote in message
news:41********@127.0.0.1...
'<' is character code 62, and '>' is character code 60 - the stream

operator
just sees them as ints - cout << "<" would work.

ad

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?



Sorry I obviously haven't posted all the code here..
but when I try
cout << "<"
it prints out the address of the "<" string.


That's the obvious giveaway. You're getting the member
operator<<(void*) not the non-member operator(char*) because
your <iostream> does not include <ostream> (that's legal, but
uncommon - hence many people forget <ostream> )
Regards,
Michiel Salters

Jul 22 '05 #9
JustSomeGuy wrote:
"adbarnet" <ad******@barnet.com> wrote in message
news:41********@127.0.0.1...
'<' is character code 62, and '>' is character code 60 - the stream

operator
just sees them as ints - cout << "<" would work.

ad

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
why would cout << '<' print 62
and cout << '>' print 60
Is there some flag that I have clobbered?



Sorry I obviously haven't posted all the code here..
but when I try
cout << "<"
it prints out the address of the "<" string.


That's the obvious giveaway. You're getting the member
operator<<(void*) not the non-member operator(char*) because
your <iostream> does not include <ostream> (that's legal, but
uncommon - hence many people forget <ostream> )
Regards,
Michiel Salters

Jul 22 '05 #10

"msalters" <Mi*************@logicacmg.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
JustSomeGuy wrote:
"adbarnet" <ad******@barnet.com> wrote in message
news:41********@127.0.0.1...
'<' is character code 62, and '>' is character code 60 - the stream

operator
just sees them as ints - cout << "<" would work.

ad

"JustSomeGuy" <no**@nottelling.com> wrote in message
news:JcJsd.415656$Pl.248656@pd7tw1no...
> why would cout << '<' print 62
> and cout << '>' print 60
> Is there some flag that I have clobbered?
>
>
>


Sorry I obviously haven't posted all the code here..
but when I try
cout << "<"
it prints out the address of the "<" string.


That's the obvious giveaway. You're getting the member
operator<<(void*) not the non-member operator(char*) because
your <iostream> does not include <ostream> (that's legal, but
uncommon - hence many people forget <ostream> )
Regards,
Michiel Salters


Ok I tried including <ostream> that didn't help...
however delving deeper into this class I found that it is inheriting from
std::streambuf and has a overflow method... and I'm thinking that somehow
to_char_type is not being called somehow.

int_type overflow(int_type ch)
{
if (traits_type::not_eof(ch))
{
if (at_start)
{
for (int i = 0; i < level; ++i)
{
if (log_on)
{
buffer->sputc(traits_type::to_char_type('\t'));
}
}
}
if (log_on)
buffer->sputc(traits_type::to_char_type(ch));
if (traits_type::eq_int_type(ch, traits_type::to_int_type('\n')))
{
at_start = true;
}
else
{
at_start = false;
}
}
return ch;
}
Jul 22 '05 #11
Rob Williscroft wrote:
Are you including <ostream> ?

#include <iostream> /* for std::cout */
#include <ostream> /* for the << operators & std::endl */


You have to include ostream separately ?! I didn't know that. I have
never had to do it even once. And I have used quite a few compilers.
Plain lucky ?

-Arijit
Jul 22 '05 #12
Arijit wrote:
Rob Williscroft wrote:
Are you including <ostream> ?

#include <iostream> /* for std::cout */
#include <ostream> /* for the << operators & std::endl */

You have to include ostream separately ?! I didn't know that. I have
never had to do it even once. And I have used quite a few compilers.
Plain lucky ?


Yes.
Jonathan
Jul 22 '05 #13

JustSomeGuy wrote:
Ok I tried including <ostream> that didn't help...
however delving deeper into this class I found that it is inheriting from std::streambuf and has a overflow method... and I'm thinking that somehow to_char_type is not being called somehow.


The hard part of bugfixing is when you have more than one bug.
Anyway, you must have mistracked somewhere. ostream doesn't have
an IS-A relation with streambut, but a HAS-A. This is important,
because you can replace that streambuf at runtime. std::cout
will have a special one that streams to the screen.

Anyway, the tricky part with the int_type is to deal with the number
of possible results when trying to get a character. There are
typically 257 results: either one of 256 characters, or EOF (-1).
That won't fit in an char, so an int is used. Streams are templatized
(work on wchar as well) and that's why you can't use int directly.
Anyway, the mapping from int to char (and to wchar_t from whatever
it maps from) is done by to_char_type. That is pretty much a no-op,
and I can't imagine that failing.

Regards,
Michiel Salters

Jul 22 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
11
by: Woolly Mittens | last post by:
I tried validating my gallery page using your validator. http://validator.w3.org/check?uri=http%3A%2F%2Fwww.woollymittens.nl%2Fcontent%2Fgallery%2Findex.asp To my surprise it informed me that...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
5
by: Grahammer | last post by:
Sorry for the whining, but I'm getty VERY frustrated trying to do some very simple jobs with DotNet and finding out that they are just impossible or involve a LOT of work. - Print a RichTextBox...
5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
56
by: Ed Jay | last post by:
I note in an Eric Meyers book that he expresses one goal of using CSS is to eliminate all <brtags. Why? -- Ed Jay (remove 'M' to respond by email)
12
by: arnuld | last post by:
It works fine. any advice on making it better or if I can improve my C++ coding skills: /* C++ Primer - 4/e * * Chapter 9 - Sequential Containers * exercise 9.18 - STATEMENT * ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.