944,176 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1715
  • C++ RSS
Dec 9th, 2005
0

spaces in binary file not showing

Expand Post »
I am trying to open a mp3 to read the ID3 tag information, when the mp3 is opened in an ASCII editor I can see all the information I want, including spaces. But...
When I try running the following chunk of code on that same mp3, I get the same thing, except all the spaces are missing.

C++ Syntax (Toggle Plain Text)
  1. for (int i=0; i<350; i++) {
  2. mp3 >> stream[i];
  3. cout << stream[i];
  4. }

I've tried opening the file as both ascii and binary, using the >>
operator and mp3.get(stream[i]) notation, but there is never a space. As a last resort I tried casting off all the characters to ints and looking at that, but the space isn't there.
Is there something I am doing wrong?
Similar Threads
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Dec 10th, 2005
0

Re: spaces in binary file not showing

its probably because what you see in the ascii editor are not spaces at all. Many editors, such as Notepad will display non-printable characters as spaces. What makes you think that file contains spaces? binary files contains all sorts of stuff that are meaningless to ascii edits. If you realy want to see what is in the file, and you are on MS-Windows os, you can use debug.exe that is in the MS-Windows installation directory -- that program has been distrubuted with every M$ operating system since MS-DOS 1.0 over 20 years ago. It has a split screen. On the left side is the hex values of every byte in the file. The right side contains the ascii values where non-printable bytes are displayed as a '.' (period).
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Dec 10th, 2005
0

Re: spaces in binary file not showing

the reason I say they are spaces is because they part of the file that I am looking at is the ID3 tag of an MP3. In the ID3 tag, you can store information about an mp3 such as the artist, album, title, etc....

When I open the file in winamp I can see the space between "The Beatles" under the artist field, and I see it in my ASCII editor.
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Dec 10th, 2005
0

Re: spaces in binary file not showing

The >> operator strips the spaces. If you want to retain them use read() function.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Doubts in i/o and others in 'C'
Next Thread in C++ Forum Timeline: Some thingthat we can do in C and Not in C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC