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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:38:57+00:00 2026-06-04T18:38:57+00:00

I have just started learning C++ so I may be way off the mark

  • 0

I have just started learning C++ so I may be way off the mark with this one but go easy on me.

What I want to do is to write to a memory address that I specify – if that’s possible?

The code I am using is:

#include <iostream>

int main()
{
    using namespace std;

    int i = 100;
    int* p = &i;
    cout << p << "\n";
    cout << "Writing" << "\n";
    int* w = (int*)0x28ff18;
    *w = 101;
    cout << *p << "\n" << "Done";
    return 0;
}

The address I get for i is 0x28ff18, so is it possible to write to that location by specifying this address? Rather than use *p = 101. Obviously what I am using doesn’t change it, I don’t know where or if it’s writing 101.

Any simple explanation or help is much appreciated.

  • 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-04T18:38:59+00:00Added an answer on June 4, 2026 at 6:38 pm

    On most computers and with most compilers, something like this will probably work. But the C++ standard does not guarantee anything about this.

    For example, when I compiled and ran your code using MSVC++ on a Windows machine, every time the address was different. You cannot expect it to be the same between different runs of the same program.

    Also note that the integer you are storing the pointer value in should be large enough (e.g., a 64-bit integer when you have 64-bit pointers). Use uintptr_t if you want to do this (thanks larsmans for pointing this out).

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

Sidebar

Related Questions

I have just started learning Cocos2d from one tutorial. I want to fly 'Bats'
I have just started learning ruby reading from different resources. One of them is
I just started learning C++ couple of weeks ago. So now I have this
Hi I have just started learning about xsd as I want to use it
I have just started learning wordpress plugin development and got this error when I
I have just started learning C# and would have one question that I cannot
I have just started learning Qt and compiled and executed this spinet #include <qapplication.h>
I have just started learning Jquery and am new to writing javascript (I am
I have just started learning MVVM and having a dilemna. If I have a
I have just started learning NHibernate. Over the past few months I have been

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.