Solved

Question about Vectors

Posted on 2006-06-11
2
229 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

695 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