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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:06:57+00:00 2026-06-14T21:06:57+00:00

I am trying to write a program using code given to me by the

  • 0

I am trying to write a program using code given to me by the author of my textbook, but I am getting “Dereferencing Pointer to Incomplete Type” errors in every method when trying to compile a program that uses the file. Below is the code. Does anyone know how I can fix this author’s code to get it to work?

#include <stdio.h>
#include <stdlib.h>
#include "StackADT.h"
#define STACK_SIZE 100

struct stackType {
    int contents[STACK_SIZE];
    int top;
};

static void terminate(const char *message) {
    printf("%s\n", message);
    exit(EXIT_FAILURE);
}

Stack create(void) {
    Stack s = malloc(sizeof(struct stackType));

    if (s == NULL) {
        terminate("Error: Stack could not be created");
    }

    s->top = 0;
    return s;
}

void destroy(Stack s) {
    free(s);
}

void makeEmpty(Stack s) {
    s->top = 0;
}

bool isEmpty(Stack s) {
    return s->top == 0;
}

bool isFull(Stack s) {
    return s->top == STACK_SIZE;
}

void push(Stack s, Item i) {
    if (isFull(s)) {
        terminate("Error: Stack is full");
    }

    s->contents[s->top++] = i;
}

int pop(Stack s) {
    if (isEmpty(s)) {
        terminate("Error: Stack is empty");
    }

    return s->contents[--s->top];
}

Error:

StackADT.c: In function 'create':
StackADT.c:29: error: dereferencing pointer to incomplete type
StackADT.c: In function 'makeEmpty':
StackADT.c:38: error: dereferencing pointer to incomplete type
StackADT.c: In function 'isEmpty':
StackADT.c:42: error: dereferencing pointer to incomplete type
StackADT.c: In function 'isFull':
StackADT.c:46: error: dereferencing pointer to incomplete type
StackADT.c: In function 'push':
StackADT.c:54: error: dereferencing pointer to incomplete type
StackADT.c:54: error: dereferencing pointer to incomplete type
StackADT.c: In function 'pop':
StackADT.c:62: error: dereferencing pointer to incomplete type
StackADT.c:62: error: dereferencing pointer to incomplete type
  • 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-14T21:07:00+00:00Added an answer on June 14, 2026 at 9:07 pm

    Try squeezing in typedef struct stackType *Stack; before the first function definition and see if that fixes it.

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

Sidebar

Related Questions

I'm trying to write a program that can stop and start services using SilverLight
i am trying to write a program in java (on linux) using RandomAccessFile class
Hi I am trying to write a program that separates words into syllables using
I'm trying to write a C program to change a user password using Linux
I am trying to write a tcp reconstruction program in c# , by using
I'm trying to read and write the data to the server using java program.
I'm trying to write a simple program using WinSnmp in C++. There is very
I am trying to write a program that reads in binary files using C++.
I am trying to write a blackjack program, but when I try to send
Hello I am trying to write a simple program for fun.. But I am

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.