?
Solved

Tab Spaces

Posted on 2003-11-04
4
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
zrh earned 120 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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