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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:56:43+00:00 2026-05-23T07:56:43+00:00

I am using an HDF5 library to read data from an HDF5 file in

  • 0

I am using an HDF5 library to read data from an HDF5 file in c++ and the call I am having problems with is the following:

status = H5Dread(
    hdf5_dataset,
    hdf5_datatype,
    hdf5_dataspace_in_memory,
    hdf5_dataspace_in_file,
    H5P_DEFAULT,
    buf
);

The last argument is supposed to be a void pointer, and I have a vector of floats that I want to be allocated, however when I try to pass the vector g++ gives me the following error:

error: cannot convert ‘std::vector<float, std::allocator<float> >’ to ‘void*’ for argument ‘6’ to ‘herr_t H5Dread(hid_t, hid_t, hid_t, hid_t, hid_t, void*)’

Is there any way that I can write directly to the vector without having to allocate the memory twice?

  • 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-23T07:56:43+00:00Added an answer on May 23, 2026 at 7:56 am

    As std::vector guarantees the data is stored in contiguous memory, you can convert a vector to a pointer like so:

    std::vector<float> myFloats;
    void *ptr = static_cast<void*>(&myFloats[0]); // or &myFloats.front()
    

    Edit: if you are writing to it without calling push_back, make sure you resize enough space first!

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

Sidebar

Related Questions

I have daily stock data as an HDF5 file created using PyTables. I would
Ok, I have the HDF5 library downloaded from the official site, and I have
I am using HDF5 to read a string into a char* allocated by new[]
I have a jar file I produced from compiled class files using an ant
How can I put a numpy multidimensional array in a HDF5 file using PyTables?
I'm using Silo with HDF5, and I'm having trouble accessing some of the metadata
I'm using h5py to access HDF5 files and store the h5py File objects in
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I've been working with HDF5 files with C and Matlab , both using the

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.