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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:33:03+00:00 2026-06-18T03:33:03+00:00

There is a header file stack.h : typedef char ElemType; typedef struct{ ElemType data[MaxSize];

  • 0

There is a header file stack.h:

typedef char ElemType;

typedef struct{
    ElemType data[MaxSize];
    int top;
} SqStack;

int Push_Sq(SqStack *s, ElemType e);

int Pop_Sq(SqStack *s, ElemType *e);

int GetTop_Sq(SqStack *s, ElemType *e);

And now I have some source file including this header, I want to use int for ElemType instead of char, is it possible? What should I do?(I don’t want to modify the original header file)

  • 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-18T03:33:05+00:00Added an answer on June 18, 2026 at 3:33 am

    Well, since you’re compiling the code, there’s nothing stopping you from editing the source file itself, or using a different source file (a slightly modified copy of the one you’ve shown), to change the underlying type to an int. In other words, changing the first line to:

    typedef int ElemType;
    

    You’ll need to be careful as that may break assumptions made elsewhere, but that would be the first thing I’d try.

    If, as stated in the edit, you don’t want to modify the original header file, you can just include it thus:

    #define char int
    #include "stack.h"
    #undef char
    

    This may work as char is only used in that header file in the typedef itself so the effects are localised.

    Keep in mind that all translation units in the current build should use that trick otherwise you may end up with some very unusual bugs.


    In my opinion, you’d be better off forking the entire stack implementation to try and keep things clean, or make the stack able to handle any data type (a little more complex, but doable).

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

Sidebar

Related Questions

Is there any header file in c or c++ to implement data structure like
There's a header file, esUtil.h, with a definition for a structure called ESContext, and
Is there a Win32 equivalent to the linux header file? I'm working on a
Assume that there's no problem with my header file and some included library. I'm
I have a header file buildTree.h and a C file buildTree.c there is a
Why must I define variables twice in the header file? What differences are there
Some classes, like exceptions or templates, only need the header file (.h), often there
I am importing data from csv file, sometimes there are column headers and some
I can easily skip the header of a data file using getline, but then
I have three files: movie.h (header); movie.cpp (implementation file); lab9.cpp (driver file using movie

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.