Solved

Tab Spaces

Posted on 2003-11-04
4
209 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

829 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