Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,838 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,593 people online right now. Registration is fast and FREE... Join Now!




Display Variable address

 
Reply to this topicStart new topic

Display Variable address

zerogee
3 Oct, 2008 - 08:06 PM
Post #1

New D.I.C Head
Group Icon

Joined: 20 Aug, 2008
Posts: 49

All i am trying to do is display address of variables. here is what i have;

CODE

#include <iostream>
using namespace std;

int main()
{
    int num, count;
    char key, choice;
    long date;
    double yield, price;

    cout << "The address of num = " << int(&num) << "\n";
    cout << "The address of count = " << int(&count) << "\n";
    cout << "The address of Key = " << char(&key) << "\n";
    cout << "The address of choice = " << char(&choice) << "\n";
    cout << "The address of date = " << long(&date) << "\n";
    cout << "The address of yield = " << double(&yield) << "\n";
    cout << "The address of price = " << double(&price) << endl;

    return 0;
}


This is the compile error i get;
error C2440: '<function-style-cast>' : cannot convert from 'double *' to 'double'
1> There is no context in which this conversion is possible

i get 2 errors and both errors are the same

This post has been edited by zerogee: 3 Oct, 2008 - 08:14 PM
User is offlineProfile CardPM
+Quote Post

GWatt
RE: Display Variable Address
3 Oct, 2008 - 09:51 PM
Post #2

human inside
Group Icon

Joined: 1 Dec, 2005
Posts: 2,191



Thanked: 18 times
Dream Kudos: 450
My Contributions
instead of int(&var) just use &var
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 05:21PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month