'Size of pointers' what does this mean ?

What does it mean when we say size of a pointer is 2 bytes under DOS and 4 bytes under windows/linux ? What does this 'size ' refer to in context of pointers ? Please help

Replies

  • Ankita Katdare
    Ankita Katdare
    Pointer is a "variable" that stores the address of another variable, right?
    Whenever we declare any variable, a random block of memory is chosen and value will be stored in that memory location.
    Similars is the case with pointers!
    Use sizeOf operator to check the size of any pointer variable.
  • Alok mishra
    Alok mishra
    Ankita Katdare
    Pointer is a "variable" that stores the address of another variable, right?
    Whenever we declare any variable, a random block of memory is chosen and value will be stored in that memory location.
    Similars is the case with pointers!
    Use sizeOf operator to check the size of any pointer variable.
    clear , say there is a pointer variable which is 2 byte large in size so what i am asking is what are these 2 bytes ,size of the address the pointer is pointing to ,or size of block of memory the pointer is pointing to (but the size of memory block the pointer is pointing to might be larger than 2 bytes ) ?
  • Aadit Kapoor
    Aadit Kapoor
    #include 
    #include 
    
    main()
    {
        int a = 12;  /* 4 bytes stored in memory system */
        int *p = &a; /* 4 bytes stores in memory system for p and now p is pointing to a variable */
    
        printf("Size of variable a = %d,Size of pointer variable p = %d\n",sizeof(a),sizeof(p)); /* Ouput :  Size of variable a  = 4 and Size of variable p = 4 */
    }
    pointer is noting but a variable that points to its type.For example int pointer variable will only point to int variables.
    But there is a void pointer which is like a generic pointer in c.It can contain any types of variables,but void pointers are not capable of pointer arithmetic operations.
  • Alok mishra
    Alok mishra
    Aadit Kapoor
    #include 
    #include 
    
    main()
    {
        int a = 12;  /* 4 bytes stored in memory system */
        int *p = &a; /* 4 bytes stores in memory system for p and now p is pointing to a variable */
    
        printf("Size of variable a = %d,Size of pointer variable p = %d\n",sizeof(a),sizeof(p)); /* Ouput :  Size of variable a  = 4 and Size of variable p = 4 */
    }
    pointer is noting but a variable that points to its type.For example int pointer variable will only point to int variables.
    But there is a void pointer which is like a generic pointer in c.It can contain any types of variables,but void pointers are not capable of pointer arithmetic operations.
    yes thats what i know but a statement in a book confused me .it(the book) was saying that pointer variables are 2 byte wide in DOS and 4 byte wide in windows/linux.
  • Anand Tamariya
    Anand Tamariya
    The size refers to the size of data type which in fact is different in DOS and other OSes. This is required by specification.
  • Aadit Kapoor
    Aadit Kapoor
    Alok mishra
    yes thats what i know but a statement in a book confused me .it(the book) was saying that pointer variables are 2 byte wide in DOS and 4 byte wide in windows/linux.
    As Anand Bhaiya said it varies from different operating system.
  • Alok mishra
    Alok mishra
    Aadit Kapoor
    As Anand Bhaiya said it varies from different operating system.
    got it
  • najeeb88
    najeeb88
    Thank so much for sharing your thought with your readers.


    #-Link-Snipped-#
  • Aadit Kapoor
    Aadit Kapoor
    Can any one tell me what is hardware engineering?
  • Alok mishra
    Alok mishra
    Aadit Kapoor
    Can any one tell me what is hardware engineering?
    hardware engineering is mainly concerned with the establishment ,look after and maintenance of computer networks but also put focus on other hardware related issues related to power supply , computer components and peripherals etc .
  • Aadit Kapoor
    Aadit Kapoor
    How to get started in hardware engineering?
  • Abhishek Rawal
    Abhishek Rawal
    Aadit Kapoor
    Can any one tell me what is hardware engineering?
    Are you interested in maintaining hardware ? Something like 'troubleshooter' for computer hardwares ?
    Or you're rather interested in 'developing' hardware & communicating hardware using programming languages ?

    Note that both are very different domain & in my opinion, latter one is rather very much interesting than the other one.
  • Aadit Kapoor
    Aadit Kapoor
    Abhishek Rawal
    Are you interested in maintaining hardware ? Something like 'troubleshooter' for computer hardwares ?
    Or you're rather interested in 'developing' hardware & communicating hardware using programming languages ?

    Note that both are very different domain & in my opinion, latter one is rather very much interesting than the other one.
    I am interested in developing hardware & communicating hardware using programming languages.
    How do i get started in this?
  • Aadit Kapoor
    Aadit Kapoor
    I am currently learning C and Data structures.
  • Abhishek Rawal
    Abhishek Rawal
    Learning programming languages is good & C is obviously good start. But don't start picking up languages one after another like all others do,stick with C/Embedded C.(Python & Vala is fun language too,just saying).Also avoid learning languages like Java or C++ for now.Learning these languages won't do anything wrong, but remember that you're dealing with hardware so it is better to consume time in learning & understanding basics of electronics & understanding hardware first, you can pick on other languages later.

    I am not in position in giving suggestions,as I am too a student myself & trying to march towards Embedded linux. But I can ask you to do same what I did :
    Understand Basics of electronics, Learn Digital logic design, Start learning 8086/80386 & Intel-51 family.
    Read Assembly language step-by-step Programming with Linux by Duntemann,awesome book!
    Fun part starts now,Buy arduino,RPi & start creating something.(I am in this phase now)

    What next ? well I don't know too, But I am planning to learn RTOS, Linux Kernel,GNU toolchain & ARM.
  • najeeb88
    najeeb88
    najeeb88
    Thank so much for sharing your thought with your readers.
    Informative post.....
  • Aadit Kapoor
    Aadit Kapoor
    Alok mishra
    yes thats what i know but a statement in a book confused me .it(the book) was saying that pointer variables are 2 byte wide in DOS and 4 byte wide in windows/linux.
    One more thing,pointers were introduced by operating system vendors,that is why it comes 2 and 4 in dos and windows respectively.

You are reading an archived discussion.

Related Posts

I've been using BSNL FTTH and the speed it offers is up to 100 Mbps. I'm curious to know which ISP in India offers Interent speeds faster than that and...
All the Nokia Asha phone users, it is time to rejoice, because WhatsApp is soon coming to the Asha 501 smartphone. Shared today on their official blog - Nokia Conversations,...
As title mentions, I would like to know the difference between Electric Field Density and Electric Field Intensity.
Indian Railway Catering and Tourism Corporation or IRCTC has launched a new scheme called the e-Wallet on its website (irctc.co.in) to helps users buy train tickets faster in India. The...
Google has rolled out a new news-reading app called Newsstand, that offers Android users a unique place to read or browse through their favorite subscriptions - newspapers, magazines, blogs and...