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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:56:06+00:00 2026-05-26T10:56:06+00:00

What the codes basically do is to print the address of each element in

  • 0

What the codes basically do is to print the address of each element in the int and char arrays pointed to by pointers i and ch.

#include<stdio.h>

int main()
{
    char *ch;
    int *i;
    int ctr;

    ch = malloc(sizeof(char)*10);
    i = malloc(sizeof(int)*10);

    printf("Index\ti Address\tch Address\n\n");

    for(ctr=0; ctr<10; ctr++)
    {
        printf("%d\t%p\t%p\n",ctr,i+ctr,ch+ctr);
    }

    getch(); 
    return  0;
}

Result:

Index   i Address       ch Address

0       00511068        00511050
1       0051106C        00511051
2       00511070        00511052
3       00511074        00511053
4       00511078        00511054
5       0051107C        00511055
6       00511080        00511056
7       00511084        00511057
8       00511088        00511058
9       0051108C        00511059 

I understand that each element in two arrays occupies space size of their data type. My problem is, I’m confused to this operation:

i+1

If i is 00511068 , then i+1 is 00511069 as opposed to the result. What does i+1 means? How do you read it? I think I don’t fully understand pointer. Please help me understand it. Thank you.

  • 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-26T10:56:07+00:00Added an answer on May 26, 2026 at 10:56 am

    Ah, yes, that old chestnut. There’s a bit of magic going on when you add N to a pointer; the compiler intuits that you want the address of the Nth item, and multiplies the offset by the size of the datatype.

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

Sidebar

Related Questions

Basically the function I am exploiting is this: int getbufn() { char buf[512]; Gets(buf);
Consider the following C program: int main(void) { char string[10] __attribute__ ((aligned(32))); int i;
I have some code that is basically 5 print statements that i would like
I have this code, which basically looks up an IP address when a user
This code basically translates characters based on position in one string to the character
My code basically needs to start up a simple chat server with a client.
I recently came across this in some code - basically someone trying to create
I have a bit of code that basically reads an XML document using the
I have a block of code that basically intializes several classes, but they are
Last evening I did some housekeeping on our code repository - basically moved the

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.