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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:17:14+00:00 2026-06-02T18:17:14+00:00

Well I’d like to do this, …since vt is a vector allocated on the

  • 0

Well I’d like to do this,

“…since vt is a vector allocated on the stack within Stl_To_Igraph_vector_ptr_t (i.e. you just declared it as a local variable and did not allocate it using malloc), it will cease to exist as soon as the function returns. You store a pointer to vt in your igraph_vector_ptr_t, but that pointer becomes invalid when you exit from the function, that’s why you are getting an error later. You have to make vt an igraph_vector_ptr_t, and use malloc to allocate it if you want it to outlive the conversion function.” by Tamas
and it was posted in Using std::vector with Igraph, I don’t know how to fill the vector v en the next code,

#include <igraph.h> 
#include <stdlib.h>

int print_vector(igraph_vector_t *v) {
  long int i, l=igraph_vector_size(v);
  for (i=0; i<l; i++) {
    printf(" %li", (long int) VECTOR(*v)[i]);
  }
  printf("\n");
}

int main() {


  igraph_vector_ptr_t vecs;
  long int i;

  igraph_vector_ptr_init(&vecs, 3);
  for (i=0; i<igraph_vector_ptr_size(&vecs); i++) {
    VECTOR(vecs)[i] = calloc(1, sizeof(igraph_vector_t));
    igraph_vector_init( (igraph_vector_t*)VECTOR(vecs)[i], 10);
  }

  igraph_vector_t *v;
  v=(igraph_vector_t*)malloc(sizeof(igraph_vector_t));
  igraph_vector_init(v, 10);

   VECTOR(v)[0]=1;//-------??????????



  igraph_vector_ptr_set(&vecs,0,v);



  for (i=0; i<igraph_vector_ptr_size(&vecs); i++) {
    print_vector( (igraph_vector_t*)VECTOR(vecs)[i]);
    igraph_vector_destroy( (igraph_vector_t*)VECTOR(vecs)[i]);
    free(VECTOR(vecs)[i]);
  }

  igraph_vector_ptr_destroy(&vecs);
  igraph_vector_destroy(v);




  return 0;
}
  • 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-02T18:17:16+00:00Added an answer on June 2, 2026 at 6:17 pm

    v is a pointer, and it looks like VECTOR expects its argument to be a value. So change VECTOR(v) to VECTOR(*v).

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

Sidebar

Related Questions

Well, how to create picture link like this up or down votes (on the
Well I have been thinking about this for a while, ever since I was
Well my situation is like this: I am generating a report as a text
well i have used an html file like these in iframe <iframe src=sample.html></iframe> is
Well, sorry for the question, is more like a general culture one (haven't found
Well, this is an interesting problem. I have an ASP.NET MVC3 Intranet application running
Well lets say i have this <table class=infoBox> <tr> <td> test </td> <td> <table>
Well, I just started to work on server side scripting , I chose PHP,
Well, I have GridView with editable field like 'TemplateField' with DropDownList. My code: <Columns>
Well, this must be a silly one. Here below is a can-not-be-simpler code in

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.