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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:54:13+00:00 2026-06-11T03:54:13+00:00

I am interested in line 6, 7 and 8 in the code below. #include

  • 0

I am interested in line 6, 7 and 8 in the code below.

#include <stdio.h>
#include <stdlib.h>

void go_south_east(int *lat, int *lon) {
  printf("Lat: %p, Long: %p\n", lat, lon);
  printf("Address of Lat: %p, Address of Long: %p\n", &lat, &lon);
  printf("Address of Lat: %p, Address of Long + 8 bytes?: %p\n", &lat, &lon+8);
  printf("Size of Lat: %lu, Size of Long: %lu\n", sizeof(lat), sizeof(lon));
  *lat -= 1;
  *lon += 1;
}

int main() {

  int latitude = 32;
  int longtitude = -64;
  go_south_east(&latitude, &longtitude);
  printf("Avast! Now at: [%i, %i]\n", latitude, longtitude);

  return 0;
}

The output I got was:

Address of Lat: 0x7fff5fbfe9e8, Address of Long: 0x7fff5fbfe9e0
Address of Lat: 0x7fff5fbfe9e8, Address of Long + 8 bytes?: 0x7fff5fbfea20 
Size of Lat: 8, Size of Long: 8

I understand that the size of the lat and long pointers are 8 bytes because they are long unsigned int. But why are they only 1 byte away from each other in the memory? Shouldn’t they be 8 bytes away from each other since their size is 8 bytes? Please advice.


Thanks for all the helpful advice. I wished I could mark everyone’s as answer but I can’t. Really appreciate it.

  • 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-11T03:54:14+00:00Added an answer on June 11, 2026 at 3:54 am

    There’s a wild mix up of completely different things and unexplainable assertions in your question.

    Firstly, I don’t see an long unsigned int pointers in your code. All pointers in your code have int * type. Where did long unsigned int come from?

    Secondly, lat and lon are data pointers. Typically, in a non-exotic C implementation all data pointers have the same size. It doesn’t matter what they point to. On your platform data pointers have 8-byte size. That means that pointers to char and well as pointers to double as well as pointers to unsigned long int will have the same 8-byte size.

    Thirdly, where did you get the idea that they are 1 byte away in memory? The very first line in your output clearly shows that they are located at 0x7fff5fbfe9e8 and 0x7fff5fbfe9e0 addresses. These addresses are exactly 8 bytes away: 0x7fff5fbfe9e8 minus 0x7fff5fbfe9e0 equals 8. So, where did your “1 byte away” come from?

    Fourthly, your code seems to suggest that &lon+8 changes the address by “8 bytes”. This is incorrect. Adding 1 to a data pointer T* shifts it by sizeof(T) bytes, which means that &lon+8 actually changes the address by 8*8=64 bytes, which is exactly what you observe in your output: 0x7fff5fbfea20 minus 0x7fff5fbfe9e0 equals 64.

    Basically, the questions you ask are directly contradicting what you observe in your output. That’s kinda makes it virtually impossible to answer. It is like showing people a red handkerchief and asking why it is green.

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

Sidebar

Related Questions

I'm interested in what the code (command line and php) would look like where
Consider following code: main.cpp: #include <iostream> typedef void ( * fncptr)(void); extern void externalfunc(void);
I came across a line of code which had something like the below #define
I am interested in doing this C code in Java: // sets n's ith
I am interested why this fragment of code produces a syntax error saying ImmutableMap
I was running the code below, which essentially does very little. It just adds
How can I pass associative array in the below code. I dont wish to
the code below is from an assignment in my text book for a simple
Apologies this is a very broad question. The code below is a fragment of
Just come across the following line of code and having a hard time finding

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.