473,396 Members | 2,050 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,396 software developers and data experts.

stream and formatting char type

When I output my char to a stream and it has a value of 11, it writes a ^B
(vertical tab). This is understandable. When I attempt to stream it back
into a char variable, it skips it because a tab is considered whitespace.

If I cast the char to int, it'll stream out an 11 so that I can read it in
plain english. Doing this same cast while streaming the value in doesn't
read the value. I have to use a temporary int variable and then assign my
char to it.

Internally I suspect the IOStream library is using the "%c" format
specification if the type is a char. Is there a way to tell the IOStream
library to use the "%d" format specification for the char type?

--
blix
Jul 22 '05 #1
1 1636
blix wrote:
When I output my char to a stream and it has a value of 11, it writes a ^B
(vertical tab). This is understandable. When I attempt to stream it back
into a char variable, it skips it because a tab is considered whitespace.
Use the "get" method instead of the extraction operator.
If I cast the char to int, it'll stream out an 11 so that I can read it in
plain english. Doing this same cast while streaming the value in doesn't
read the value. I have to use a temporary int variable and then assign my
char to it.
I think you've got the assignment backwards. Assign the int to the
char, not the char to the int.
Internally I suspect the IOStream library is using the "%c" format
specification if the type is a char. Is there a way to tell the IOStream
library to use the "%d" format specification for the char type?


You could overload >> in the local namespace, but may I suggest you not
bother?

Jul 22 '05 #2

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

Similar topics

5
by: Jonathan Halterman | last post by:
I have a pointer to a buffer of bytes that I receive from a tcp stream that I would like to place into some kind of stream that can I can then use to serialize the data into into individual...
24
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
8
by: Marc Gravell | last post by:
I want to write a method that will accept a stream as a parameter, and which will write xml to the stream (based in reality on database results) using the XmlTextWriter class. However, this insists...
15
by: Marcus Kwok | last post by:
How do you save the formatting options for a stream? In the program below, notice that when I define my operator<<() for the custom type, it permanently changes the output format of the stream: ...
4
by: Fresh_Air_Rider | last post by:
Hi In the "good old" Classic ASP days, I used to stream records from a SQL Server database out to the user's browser in CSV format by using a combination of COALESCE and the ADODB.Stream object....
9
by: anachronic_individual | last post by:
Hi all, Is there a standard library function to insert an array of characters at a particular point in a text stream without overwriting the existing content, such that the following data in...
1
by: pax82 | last post by:
hi, sorry for my english but i don't speak good english. in this web service i send 2 data stream(xml and xsl file) and i would like to return a xslt trasform-file byte array (now i return string...
1
by: Alexander Korsunsky | last post by:
Hi! Is it possible to extract the mode flags of a stream (FILE* stream or fstream - object), without looking at how the stream was opened? What I mean by mode flags is wether the stream is opened...
27
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I have a fully-portable C program (or at least I think I do). It works fine on Windows, but malfunctions on Linux. I suspect that there's something I don't know about the standard input stream...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.