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

  • Home
  • SEARCH
  • 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 8650147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:44:50+00:00 2026-06-12T13:44:50+00:00

I have a structure declared and allocated in this way typedef { char* a;

  • 0

I have a structure declared and allocated in this way

typedef {
      char* a; char* b; int c; int d; FILE *e;
} t;
[...]

    ready= malloc(sizeof(t));
    strncpy (ready->a, ss1, length);
    strncpy (ready->b, ss2, length);
    ready->c= f; ready->d= g;
    ready->e= fopen(file, "w");

that I want to pass to a thread with

pthread_create(thread_id, NULL, worker_start, &ready);

when I begin to do some stuff in the thread function it’s clear that the fields that I had initialized in the main before calling the create are not defined in the thread.

void* worker_start(void *param) {
    t *current;

    current = (t*) param;
    ...
}

What’s wrong with the code? Am I doing something bad here?

  • 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-12T13:44:51+00:00Added an answer on June 12, 2026 at 1:44 pm

    When you’re passing the pointer to the thread, you pass it as a pointer to pointer (due to you using the address-of operator &). You don’t need to do that, and in the thread function you don’t treat it as a pointer-to-pointer but just plain pointer.

    Remove the ampersand (&) when creating the thread and things should work much better.

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

Sidebar

Related Questions

I have the STRUCT1 Structure declared as below typedef struct struct1 { short int
I have declared a structure that look like typedef struct { char* key; char*
I have a structure: typedef struct stock { const char* key1p2; // stock code
I have an array of typedef structure. It is declared as such: vertex vertexArray[numberVertices];
gcc 4.4.4 c89 I have this in my header file. port.h struct struct_tag; int
(In C++) I have a class whose structure is declared in a header file.
I'm trying to use a file pointer that I have declared in a structure
I have a header file a.h and inside that I have declared one structure.
I have structure like this. <ul class=gallerylist> <li> <image ...> <input ...> </li> <li>
I have a structure like this struct structure { BaseObject &A; //BaseObject has a

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.