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 672521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:29:39+00:00 2026-05-14T00:29:39+00:00

Know this might be rather basic, but I been trying to figure out how

  • 0

Know this might be rather basic, but I been trying to figure out how to one after create a dynamic array such as

double* data = new double[size];

be used as a source of data to be kept in to a binary file such as

ofstream fs("data.bin",ios:binary");
fs.write(reinterpret_cast<const char *> (data),size*sizeof(double));

When I finish writing, I attempt to read the file through

double* data = new double[size];
ifstream fs("data.bin",ios:binary");
fs.read(reinterpret_cast<char*> (data),size*sizeof(double));

However I seem to encounter a run time error when reading the data. Do you guys have any advice how i should attempt to write a dynamic array using pointers passed from other methods to be stored in binary files?

  • 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-05-14T00:29:39+00:00Added an answer on May 14, 2026 at 12:29 am
    1. Hy:)
    If you use Unix you have some functions:    int read(int fd, void
    

    *buf, int count);. int write (int fd, void *buf, int nbytes);.

    The functions are verry fast because
    are kernel-functions.
    
    i run your code and everything was
    ok : 
    
          1 #include <iostream>
          2 #include <fstream>
          3 #include <cstring>
          4 using namespace std;
          5 
          6 int main()
          7 {
          8     double * s;
          9     int ns = 10;                    //information
         10     s = new double[ns];
         11 
         12     for (int i = 0 ; i < ns ; ++i)
         13         s[i] = 17*i + 23;           // i put my information here
         14 
         15     ofstream os("data.txt", ios::binary);
         16     os.write(reinterpret_cast<const char*> (s), sizeof(double) * ns);
         17     os.close();
         18 
         19     double * final;
         20     final = new double[ns];
         21 
         22     ifstream is("data.txt", ios::binary);
         23     is.read(reinterpret_cast<char *>(final), sizeof(double) * ns);
         24     is.close();
         25 
         26     for (int i=0; i < ns; ++i)
         27         cout<<s[i]<<" "<<final[i]<<"\n";
         28 
         29     return 0;
         30 }
    
    ~            
    
    none@Brusture:~/Desktop$ g++ -o test
    test.cpp  none@Brusture:~/Desktop$
    ./test  23 23 40 40 57 57 74 74 91
    91 108 108 125 125 142 142 159 159
    176 176
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is not pretty but it works: rm -R $(ls… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer Yes. Override the base1 and base2 methods in Derived to… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer No, you can't. Unfortunately, UIEvent doesn't expose any public way… May 16, 2026 at 12:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I know this topic is bit old, but i did surf the web and
this might be quite a newbie question, but i need to process a certain
This is a shoutout as I've been spending the last few days learning about
This may be a bit of daft question, but I don't come from an
This is not a real situation; please ignore legal issues that you might think
I know this can't be done with iFrames or the default jQuery load function,
Does anyone know any good chart api for a web application in java? This
One thing that has driven me nuts about SharePoint2007 is the apparent inability to
so i am getting an uncaught exception and im not sure why. this is
I need to process large image files into smaller image files. I would like

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.