Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Tab Spaces

Posted on 2003-11-04
4
Medium Priority
?
214 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

636 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