Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:19:14+00:00 2026-06-18T11:19:14+00:00

I have the following code (C++) vector<unsigned char> bytes; bytes.push_back(‘e’); bytes.push_back(‘P’); bytes.push_back(‘R’); bytes.push_back(‘f’); …

  • 0

I have the following code (C++)

vector<unsigned char> bytes;
bytes.push_back('e');
bytes.push_back('P');
bytes.push_back('R');
bytes.push_back('f');

...

ofstream file(compiledFile, ios::out | ios::binary);
file.write((const char*) &binary[0], binary.size());
file.close();

but as a result is output file I have
“rPRf”
instead of bytes.

What I’m doing wrong? I need “65505266” bytes as a result.

Thank you all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:19:15+00:00Added an answer on June 18, 2026 at 11:19 am

    e, P, R and f are bytes. The file is 4 characters (bytes) long and it contains what you put there.

    The only difference between a “binary file” and a “text file” is how linebreaks are read/written on Windows (and maybe some other special characters on very old OSes). The only difference between the character e and the number 65 is how the program that you’re using to read the file chooses to display it. A text editor will display e and a hex editor will display 65.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: set< vector<int> > set_of_things; vector<int> triplet(3); //set_of_things.push_back(stuff) - adding
i have following code for copying content of vector into file #include<iterator> #include<algorithm> #include<fstream>
I have the following code (compiler: MSVC++ 10): std::vector<float> data; data.push_back(1.0f); data.push_back(1.0f); data.push_back(2.0f); //
I have the following code: void foo() { vector<double> v(100,1); // line 1 //
I have the following code: #include <iostream> #include <vector> using namespace std; struct A{};
I have the following C++ code: typedef istream_iterator<string> isi; // (1) vector<string> lineas(isi(cin), isi());
In the following code, i have a method to get a Vector of persons
I have the following code: const uint8_t HEADER_SIZE = 0x08; std::vector<uint8_t> a, b; uint8_t
I have the following code: vector<vector<Obj> > vectObjVects(10); vectObjVects[0].reserve(100); During runtime, at the third
Lets say we have the following code: std::vector<int> f() { std::vector<int> y; ... return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.