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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:10:37+00:00 2026-05-27T16:10:37+00:00

Is it possible to check what type the variable is at any given point

  • 0

Is it possible to check what type the variable is at any given point throughout the code?

For instance, say, i declare char y = 1; and function int SomeFunction (int). I then will pass y to someFunction, it will get converted to an int and ultimately int will be returned.

I know this because of function declaration. I would like, however to confirm that inside someFunction, variable is in fact of type int and variable returned from someFunction is as well an int.

Can this be done in C, or function declaration should be relied upon instead? Does C programming language provide any mechanism to check variable type at runtime?

  • 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-27T16:10:38+00:00Added an answer on May 27, 2026 at 4:10 pm

    In your code, you can rely on the fact that the types you are handed correspond to how they were declared. You couldn’t write any non-trivial program if that wasn’t the case.

    Type information, in C, is only available at compile time though. At runtime, none of that information is present so there is no standard build-in way of, for example, telling what type of object is hiding behind a random pointer.
    If you need that kind of information, see if your compiler has extensions for it (I don’t know if any do), or use frameworks that provide infrastructure for that (glib has things like that I believe).
    Or roll your own if you really really need it.

    Or use C++ which does have some runtime type information support, and generally speaking a more intricate type system, but that’s a totally different language.

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

Sidebar

Related Questions

Simple question. Is it possible to check the type of a variable that is
Possible Duplicate: How can I code a C# function to accept a variable number
Is it possible to check if a char has been passed into a method
I'm using this is_enum function to check if a variable is an enum or
Does anybody know of a way to automatically find any variable, where the type
Is it possible to check the code and find all places where conversion errors
Is it possible to check the validity of your JavaScript code, even modern techniques
I want to check if a generic variable is of a certain type but
Is it possible to cast a variable as a type dynamically, where the type
Is it possible to check a bash script syntax without executing it? Using Perl,

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.