?
Solved

Question about Vectors

Posted on 2006-06-11
2
Medium Priority
?
230 Views
Last Modified: 2010-04-01
I have a vector of structs:

std::vector <teststruct> vec;

I am reading in the struct from a file -


teststruct *var11 = (teststruct*)malloc(sizeof(teststruct));

fread(var11, sizeof(char), sizeof(teststruct), file1);

I am trying to store this struct into an array using push_back but I receive an error message stating that push_back does not exist.  

    vec.push_back(var11);
0
Comment
Question by:jewee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
chip3d earned 2000 total points
ID: 16882372
hi jewee, try

vec.push_back(*var11);

push_back of std::vector <teststruct> expect a type of teststruct and not teststruct*
0
 

Author Comment

by:jewee
ID: 16882389
Funny, i thought I tried that.  It works.  Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question