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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:48:49+00:00 2026-05-30T07:48:49+00:00

I have this ordered List structure that has a structure that has two members,

  • 0

I have this ordered List structure that has a structure that has two members, an array of type Titem and an int counter. Now, this List can take any type and arrange it in ascending order. Suppose, i decided to typedef char Titem, then the array contains characters, if i typedef int Titem, then the array contains integers. Now, I have a structure somewhere with the type Tage;

how do i make the Ordered List identify it. when i did typedef Tage Titem, it complains. Where should I insert it in the OList header file? Or is there a way to do forward declarations like it is done in C++ in C?

 #ifndef OLIST_H
 #define OLIST_H



       /*typedef char Titem; here, i typedef char to Titem, though commented out..
       how do i do similar thing for the Tage datatype i have?

       */


       #define MAX 10
       typedef struct  {
   int count;
   Titem array[MAX]; //Titem is not typedefed yet, so error..
    } TOrderedList;



  void initialize_list(TOrderedList *list);
  int insert_item(TOrderedList *list, Titem item);
  int retrieve_ith(const TOrderedList *list, int i, Titem *item);
  int number_of_items(const TOrderedList *list);
  int list_empty(const TOrderedList *list);

  #endif    
  • 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-05-30T07:48:50+00:00Added an answer on May 30, 2026 at 7:48 am

    Or is there a way to do forward declarations like it is done in C++ in C?

    No, You cannot use Forward declaration here.

    Rationale for why Forward declaration will not work:

    When you use forward declaration of any type, the compiler does not know the composition of it nor the members inside it, the compiler only knows that the type exists. Thus, it is an Incomplete type for the compiler. With Incomplete types , One cannot create objects of it or do anything which needs the compiler to know the layout of the type or more than the fact that it is just an type. Since pointers to all objects need just the same memory allocation, You can use the forward declaration when just reffering to types as a pointer.
    However, here the compiler needs to know the layout and size of the type Titem since it needs to know how much memory to allocate while creating an array, hence forward declaring the type Titem will not work.

    Solution:

    You need to let the compiler know of the layout of Titem and the way to do that is to include the header defining the type Titem in the source file where you create the array,

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

Sidebar

Related Questions

I have a nested ordered list with this structure <ol> <li> <span>A</span> <ol class=childol>
My model contains a class Section which has an ordered list of Statics that
I have four level data structure defined like this: Dictionary<Type1, Dictionary<Type2, Dictionary<Type3, List<Type4>>>> The
I have an HTML ordered list, that I need to apply a strikethrough to.
I have a nested oredered list which i m animating using this code... var
I have this code in jQuery, that I want to reimplement with the prototype
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I need a data structure that Must be ordered (adding elements a, b and
I have product list ( 9 products in multidimensional array ), i want to
You may have noticed that we now show an edit summary on Community Wiki

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.