473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Character Address

Dear All,

In my program I need to store a character and also display its address. The program is like this

char a='C';
cout<<a<<'\n';
cout<<&a;

I am expecting program to display value of a as character 'C' and in the next line to display its memory address. But it displays value 'C' on both the occassions.

Can some one explain me why this is so?

With regards,

CPLUSPLUS
Aug 28 '07 #1
2 1606
gpraghuram
1,275 Expert 1GB
Dear All,

In my program I need to store a character and also display its address. The program is like this

char a='C';
cout<<a<<'\n';
cout<<&a;

I am expecting program to display value of a as character 'C' and in the next line to display its memory address. But it displays value 'C' on both the occassions.

Can some one explain me why this is so?

With regards,

CPLUSPLUS
In c++ u have to typecast the pointer to (void*) and print it.
like this
Expand|Select|Wrap|Line Numbers
  1. cout<<(void*)&a<<"\n";
  2.  
Raghuram
Aug 28 '07 #2
In c++ u have to typecast the pointer to (void*) and print it.
like this
Expand|Select|Wrap|Line Numbers
  1. cout<<(void*)&a<<"\n";
  2.  
Raghuram
Thanks Mr. Raghuram,

It solves the problem.

Niranjan
Aug 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Michael | last post by:
I mean how to use _tprintf().
10
by: Albretch | last post by:
.. Can you define the Character Set for particular tables instead of databases? . Which DBMSs would let you do that? . How do you store in a DBMS i18n'ed users' from input, coming over the web...
9
by: Safalra | last post by:
The idea here is relatively simple: a java program (I'm using JDK1.4 if that makes a difference) that loads an HTML file, removes invalid characters (or replaces them in the case of common ones...
5
by: Paul Aspinall | last post by:
Hi I want to send an ASCII character string / stream to an IP address. I basically have 6 barcode printers, and a web interface. Depending on what is entered on the web page, will determine...
1
by: softap | last post by:
I have a PHP routine which parses my incoming emails and extracts certain key data from the body text. This works fine normally, but occasionally an email may contain the name and address of...
12
by: amer.terzic | last post by:
Here's what my code is supposed to do (it seems to work fine) Take a char* array and remove a first character from it....as simple as that. The mentioned char* array is a 'global' var shared...
8
by: Polaris431 | last post by:
I have a buffer that holds characters. Four characters in a row represent an unsigned 32 bit value. I want to convert these characters to a 32 bit value. For example: char buffer; buffer =...
14
by: Lambda | last post by:
I'd like to create separate character pointers, pass them to a function to assign each one different value, and assign the pointers to an array. But when I try: #include <stdio.h> #include...
7
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.