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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:25:18+00:00 2026-05-29T21:25:18+00:00

Ive been working at this problem for about a week, I have looked up

  • 0

Ive been working at this problem for about a week, I have looked up plenty of “incompatible pointer type” warning solutions but I’m still confused as to how I can fix this compile error.

I get an error saying:

char_stack_interface.c: In function ‘pop_char’:
char_stack_interface.c:32: warning: passing argument 2 of ‘pop’ from incompatible pointer type
char_stack_interface.c: In function ‘top_char’:
char_stack_interface.c:43: warning: passing argument 2 of ‘top’ from incompatible pointer type

This is my code:

char_stack_interface.h:

#ifndef _CHAR_STACK_INTERFACE_H
#define _CHAR_STACK_INTERFACE_H

#include "stack.h"

extern status push_char(stack *p_s, char  c);
extern status pop_char (stack *p_s, char *p_c);
extern status top_char (stack *p_s, char *p_c);

#endif

stack.h:

#ifndef _STACK_H
#define _STACK_H

#include "globals.h"

ABSTRACT_TYPE(stack);

extern status init_stack (stack *p_S);
extern bool   empty_stack(stack *p_S);
extern status push       (stack *p_S , generic_ptr data);
extern status pop        (stack *p_S , generic_ptr *p_data);
extern status top        (stack *p_S , generic_ptr *p_data);

#endif

char_stack_interface.c:

#include <stdio.h>
#include <stdlib.h>
#include "char_stack_interface.h"
#include "stack.h"

status push_char(stack *p_s, char c)
{
    char *p_c = NULL;
    p_c = (char *) malloc(sizeof(char));

    if (p_c == NULL)
        return ERROR;

    *p_c = c;

    if (push(p_s, p_c) == ERROR) {
        free(p_c);
        return ERROR;
    }

    return OK;
}
status pop_char (stack *p_s, char *p_c)
{
    char *p_data;

    if (pop(p_s, p_data) == ERROR)
        return ERROR;

    *p_c = *p_data;

    free(p_data);

    return OK;
}
status top_char (stack *p_s, char *p_c)
{
    char *p_data;

    if (top(p_s, &p_data) == ERROR)
        return ERROR;

    *p_c = *p_data;

    return OK;
}
  • 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-29T21:25:20+00:00Added an answer on May 29, 2026 at 9:25 pm

    Well whatever the generic_ptr type is, obviously the compiler is not able to automatically cast your ‘char *’ type into generic ptr type. Try doing an explicit case of your second arg to pop and top e.g.:

    pop(p_s, (generic_ptr)p_data)

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

Sidebar

Related Questions

I've been working on this for about an hour and looked at all related
I've been working on this application but have come across a problem that I
Alright, some of you might have noticed I've been working on this problem off
I've been working a little with DevExpress CodeRush and Refactor! Pro this week, and
I've been struggling with this problem for 5 hours and I have a feeling
I've been reading a lot about this problem but I get nothing that suggests
I have a constraint problem I've been working on, which has a couple fun
I've been working with this for about 2 days now. I'm stuck, with a
I been working the whole week to troubleshot a production error. I have eventually
I have a website that i've been working on for about a year now.

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.