Solved

Tab Spaces

Posted on 2003-11-04
4
210 Views
Last Modified: 2010-04-02
Hi,
I have some problems with a tab character. I have a binary file that I need to convert to Integers. I am reading each byte in the binary file and converting that to an integer by type casting.

My data contains some tab characters in between. So is the tab character read as one character or 4 spaces. This tab character is screwing my output file.

I want to know how to deal with these tab characters.


Thank you very much for your help.



ifstream infile("Data.txt", ios::in|ios::binary);
ofstream outfile2("trans.txt");


int outInt;      
char data, datamsb;
infile>> data;
infile>>datamsb;


outInt = data;
outfile2<<outInt<<endl ;
0
Comment
Question by:dinkarece
4 Comments
 
LVL 6

Accepted Solution

by:
zrh earned 30 total points
ID: 9682153
A tab is one character: '\t'
Hope that helps,
ZRH
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 9683862
A tab is a single character with a value of 9 '\t'.  However, it is unusual to have tab characters
embedded in binary data within a file.  How do you tell the difference between a tab character
and a number whose value just happens to be 9?
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10242519
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: zrh {http:#9682153}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question