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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:40:24+00:00 2026-05-30T20:40:24+00:00

For a school prject we have to work with pointers, for this i wanted

  • 0

For a school prject we have to work with pointers, for this i wanted to see the adresses of the memory but …
When i use the next piece of code :

int _tmain(int argc, _TCHAR* argv[]){
  char a;
  char b;
  char * pa;
  char * pb;
  pa = &a;
  pb = &b;
   
  cout << "adress pa "<< pa <<endl;
  cout << "adress pb "<< pb <<endl;

  cout << "a is  " << a << endl;
  cout << "b is  " << b << endl;

i get this as output :
enter image description here

Is this a characterset problem and most importantly can i correct this ?

I have tested another piece of code :

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{int x = 25;
int * p;
p = &x;
cout << "adres" << p << endl;
*p = 10;
cout << "x"<< x << endl;
cin.get();

    return 0;
}

and the output is readable :
enter image description here

What is different ?

  • 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-30T20:40:25+00:00Added an answer on May 30, 2026 at 8:40 pm

    It is because you are dereferencing uninitialized pointers. This is undefined behavior.

    One of the overloads of << operator in the C++ standard library interprets char* as a C string, not as a pointer. Sine your C string is not initialized, the << operator prints junk. There is no similar overload for int* that would interpret it as anything other than a pointer, hence you see the correct behavior in the second case.

    If you do not want your char* pointer to be interpreted as a C string, cast your pointer to void*.

    cout << hex << static_cast<void*>(pa) << endl;
    

    (hex lets you show the pointer using a more conventional base-16 notation).

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

Sidebar

Related Questions

We have been using Google Code SVN to store a school project. As we
I have a project for school and I have to use Java. Recently I
I have to install object store for a school project and it doesn't work
I apologize for this school-book question but I've been working on this SQL query
I'm developing a Grails application to a school work. Typically, this is the URL
I have been asked for a school project to submit my work by pushing
I have a school project and i want to dedicate this for New Year,
I have a school project in which I have to implement a chat application,
I have a school project in which we're going to write a financial engine
Hello I am in the process of doing a school project, where we have

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.