Solved

Tab Spaces

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now