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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:36:31+00:00 2026-05-31T05:36:31+00:00

We have the following code: #include <stdio.h> #define LEN 10 int main(void) { int

  • 0

We have the following code:

#include <stdio.h>
#define LEN 10

int main(void) {
    int i;
    int array[LEN];
    int *p;
    for (i = 0; i < LEN; i++) {
        array[i] = i;
    }
    for (p = &array[0]; p < &array[LEN]; p++) {
        printf("Address: %p   ", p);
        printf("Value: %d\n", *p);
    }
    return 0; 
}

And it asks us to find out how many bytes the sever uses to store an integer variable, and print it on a newline, and it gives us the hint to use sizeof.

Now, I’m a bit of a noob with pointers, so this is probably a really quick question, but should I print:

printf("Size of int: %d", sizeof(p));

or sizeof(*p)

One prints 4, and the other prints 8. I was leaning toward 8 (which comes from simply p) as it refers to the memory location, not the variable it’s pointing to’s value, right? And 8 would mean 8 bits, so 1 byte would be the answer?

  • 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-31T05:36:33+00:00Added an answer on May 31, 2026 at 5:36 am

    An easy solution to your particular problem is to use sizeof on the type name:

    sizeof(int)
    sizeof(int *)
    

    You’ll get the answers you need without any confusion.

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

Sidebar

Related Questions

i have the following code: #include <stdio.h> int main(void) { float a[4] __attribute__((aligned(0x1000))) =
I have the following code: #include <string.h> int main(void) { char *buffer = NULL,
I have the following code: #include <stdlib.h> #include <stdio.h> #define SIZE 100 int* arr;
I have the following code: #include <stdlib.h> #include <stdio.h> #include <pthread.h> #define NUM_THREADS 100
I have the following code: main.c #include checksum.h void main() { char *Buf =GPGGA204502.005106.9813N11402.2921W1090.91065.02M-16.27M;
i have found following code on online for suffix tree #include <stdio.h> #define E
This is an ANSI C question. I have the following code. #include <stdio.h> #include
I have the following code: #include <boost/shared_ptr.hpp> struct Foo { int a; }; static
I'm using gcc 4.3.2. I have the following code (simplified): #include <cstdlib> template<int SIZE>
Please have a look at the following code: #include <stdio.h> #include <stdlib.h> typedef struct

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.