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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:18:18+00:00 2026-06-01T22:18:18+00:00

Which line is the correct (best) way for defining a pointer? typedef ptrdiff_t pointer;

  • 0

Which line is the correct (best) way for defining a pointer?

typedef ptrdiff_t pointer; // pointers are ptrdiff_t.

          -- or --

typedef void* pointer; // pointers are void*.


pointer ptr = malloc(1024);
  • 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-01T22:18:19+00:00Added an answer on June 1, 2026 at 10:18 pm

    Pointers in C are of type T* where T is the type pointed to; void* is the generic pointer type. Usually, you let C implicitly convert void* to something useful, e.g.

    char *buffer = malloc(1024);
    

    ptrdiff_t is the type returned by the subtraction of two pointers, e.g.

    ptrdiff_t d = write_ptr - buffer;
    // now you know the write_ptr is d bytes beyond the start of the buffer
    

    ptrdiff_t is an integral type, not a pointer type; you cannot use the indirection operator * on it. (Nor can you meaningfully use it on a void*, by the way.)

    Had you wanted to store a pointer in an integer type, uintptr_t would have been appropriate.

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

Sidebar

Related Questions

Firefox 3 has introduced a new behavior in which line-height, when unset, differs from
I have a html table in which each line ( <tr> ) represents a
I have a file in which each line contains two numbers. The problem is
This is my code in which every line is giving me an invalid context
I have to read CSV files line by line which can be 10 to
I have a script in which I have a line which does put the
I want to extract some numbers from the input line which is a string.
It's seen in UITextView and UITextField - the flashing blue line which shows you
I am trying to write some code that that will draw the line which
Currently, each td../td prints in just 1 line which makes the source code very

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.