Solved

Question about Vectors

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C++ - Convert a wString to char * 9 428
Rijndael string encryption in C++ 3 93
Getting IP address 8 67
Dialogbox API leak? 18 59
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now