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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:58:11+00:00 2026-06-14T01:58:11+00:00

I am trying to have a dictionary_object structure named dict_obj available in two separate

  • 0

I am trying to have a dictionary_object structure named dict_obj available in two separate .c files. This is while trying to write a pthread TCP server for a class. I have not worked much with C before and am having a difficult time getting this figured out. I’m not sure if I’m declaring this as an external structure correctly as netbeans is throwing off errors on clean and build saying invalid use of undefined type.

In db_functions.c I have:

//------------------------------------------------------------------------------
//                Server Function & Variable Initialization 
//------------------------------------------------------------------------------

struct dictionary_object dict_obj;


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//                            Server Function Codes:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------



//------------------------------------------------------------------------------
//                         Database Initialization
//------------------------------------------------------------------------------

int db_initialization()
{

    dict_obj.word_count = 0;
    return 1;

In db_operations.c I have:

struct dictionary_object
{
    char dictionary[DICTIONARY_SIZE][WORD_LENGTH];
    int word_count;
    pthread_mutex_t dict_mutex;

};

extern struct dictionary_object dict_obj;

Hopefully this gives you guys enough idea of what I’m trying to accomplish without having to overwhelm you with too much code. Thanks in advance! Let me know if you need to see more of the code.

  • 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-14T01:58:12+00:00Added an answer on June 14, 2026 at 1:58 am

    You need to define the structure contents and layout once in an include file. Also define the “extern” definitions for all functions and statics for the code there. In any file wanting to use those structs or definitions, include the header file (something like db_struct.h).

    db_struct.h:

    struct dictionary_obhect {
       char dictionary ...
    }
    extern struct dictionary_object dict_obj;
    extern int db_initialization();
    

    db_struct.c:

    #include "db_struct.h"
    
    struct dictionary_object dict_obj;
    int db_initiatilization() {
        dict_obc.word_count = 0;
    }
    

    Note this is all pretty old-style C code. Modern C++ etc. have other means of doing similar things.

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

Sidebar

Related Questions

Afternoon, I am trying have an HTML file containing a frameset which contains two
I am trying to have a table like this: Manager Expert Adminis. Staff Dept
I have this scenario in which memory conservation is paramount. I am trying to
I'm trying to create specific object pool in c# . I have two basic
So I have a dictionary in a dictionary with arrays. I am trying to
I am trying to implement vectorization of a text file...I have created a dictionary
I'm trying to map a Dictionary containing Lists. I have the following set of
Trying to have my PHP script return some SQL table queries. Here's my script
I have trying to learn MVC4 Web API. I am running my project from
I have a cache directory I'm trying to have ignored by git which lives

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.