Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Output MP3 contents as binary/hexadecimal
Output MP3 contents as binary/hexadecimal [message #1833206] Tue, 06 October 2020 14:17 Go to next message
Kyle Roseberry is currently offline Kyle RoseberryFriend
Messages: 1
Registered: October 2020
Junior Member
I am fairly new to C++ and Eclipse.

I figured out how to open an MP3 file and output the contents of the file to the console, but it is displayed in a coded format. I am trying to look for patterns so I need the fstream to be binary (or hexadecimal is fine). When I output the content of the fstream to the console I get:


File is open!
ID3 bTIT2 Stupid Song

(Truncated for simplification)

What I expect is what I see when I open the mp3 in a hex editor:

33 03 00 00 00 01 09 62 54 49 54 32 00 00
00 00 00 52 74 75 70 69 64 20 53 6F 6E 67


What am I doing wrong? Is it a console setting, an issue with it being a string? Something else entirely? Thanks for your help!

// Name        : Open_A_File.cpp
// Author      : Kyle Roseberry
// Description : Hello World in C++, Ansi-style

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main() {

	string line;
	ifstream myfile;

	myfile.open("src/Test.mp3", std::ios::binary);

	if (!myfile.is_open())
	{
	    cout << "Cannot read file!" << endl;
	}
	else
	{
		cout << "File is open!" << endl;
		while ( getline (myfile,line) )
		    {
		      cout << line << '\n';
		    }
	    myfile.close();

	}
	cout << "Done!" << endl;
	return 0;
}
  • Attachment: Open_A_File.cpp
    (Size: 1.17KB, Downloaded 122 times)
  • Attachment: Test.mp3
    (Size: 5.45MB, Downloaded 84 times)

[Updated on: Wed, 07 October 2020 19:48] by Moderator

Report message to a moderator

Re: Output MP3 contents as binary/hexadecimal [message #1833260 is a reply to message #1833206] Thu, 08 October 2020 06:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Are you sure your post isn't merely a post intended to attach an *.mp3 file? In any case, your post isn't asking how to use Eclipse's tools but rather how to program in C/C++. It appears to me that you're reading a binary file and hoping to print it out in hex, but I'm not sure what makes you think hex should be printed just by reading a line from a binary file. Perhaps try a more general forum such as stackoverflow for general programming questions.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Hello every one
Next Topic:JavaFX Help Needed
Goto Forum:
  


Current Time: Thu Apr 25 01:15:21 GMT 2024

Powered by FUDForum. Page generated in 0.07997 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top