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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:00:06+00:00 2026-06-09T22:00:06+00:00

I have got file with vector of : typedef struct { float fX; ///<

  • 0

I have got file with vector of :

typedef struct {
    float fX; ///< position X
    float fY; ///< position Y
    int iSize; ///< Size of point   
} structParams;

but I would like to read it to vector of nearly the same struct but without iSize

typedef struct {
    float fX; ///< position X eq. structParams.fX
    float fY; ///< position Y eq. structParams.fY
} structPositionParams;

Can I do this in similar way to

ifstream inStr("file.dat");
vector<structPositionParams>  oVector;
oVector.(numOfElements);
inStr.read((char*)&oVector[0], sizeof(structPositionParams) * numOfElements);
inStr.close();
  • 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-09T22:00:08+00:00Added an answer on June 9, 2026 at 10:00 pm

    You’ve got to utilize the stride of the data. Since the standard library doesn’t support reading strided data in any way, either you read the whole file, and then run a for loop creating objects from that data, or do whole reading in a for loop, skipping sizeof(int) after each object.

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

Sidebar

Related Questions

I have running process but it's executable file has got deleted. If I try
I have got the following in a header file for a class: #include <vector>
I have got this text file with latitude and longitude values of different points
I have got a single file in which I need specify classes in multiple
Can't understand what is a problem here: I have got main.cpp file where I
I have got the requirement to find the core file in multiple box/machine and
I have got a huge tab-seperated file with up to 200 million rows (normally
We have got an extjs 3.1.1 form with file upload field ( http://www.extjs.com/deploy/dev/examples/form/file-upload.html from
I am generating a rss(xml) output form a php file. I have got a
I've got an XML file on my server, and my partners have to access

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.