Solved

Question about Vectors

Posted on 2006-06-11
2
227 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
2 Comments
 
LVL 4

Accepted Solution

by:
chip3d earned 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

840 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