Thread: Address of variables?

  1. #1
    Registered User
    Join Date
    Feb 2008

    Address of variables?

    I was trying to figure this problem out. I know that if the address for each variable were not in this problem, i =14 j = 7 p=14 q=7...How does adding in the address for this program affect the output of the variables?

    Consider the program below. Fill in the values for variables 'i', 'j', 'p', 'q' after the
    code fragment has executed. The table below shows the address of each variable
    in memory (e.g. variable 'i' is stored at address 2000). For each answer, enter an integer left justified with no leading zeroes.

    int i = 12, j = 14;
    int *p, * q;
    p = &i;
    q = &j;
    *p = *q;
    *q = 7;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    It doesn't change anything, it's just to help you visualise actual storage.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  3. HelpMePlease
    By Prncess100 in forum C++ Programming
    Replies: 6
    Last Post: 12-11-2002, 02:02 PM
  4. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM
  5. MSN Vital Information
    By iain in forum A Brief History of
    Replies: 9
    Last Post: 09-22-2001, 08:55 PM