tomadom's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Active Members
Active Posts:
71 (0.14 per day)
Joined:
11-December 12
Profile Views:
1,116
Last Active:
User is offline Feb 10 2014 08:31 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   tomadom Is here

Posts I've Made

  1. In Topic: buffer <<= 4 ?

    Posted 8 Feb 2014

    thanks
  2. In Topic: error: cannot convert 'int**' to 'int*' in assignment

    Posted 3 Feb 2014

    I think I've just clicked. Thanks for the help.
  3. In Topic: error: cannot convert 'int**' to 'int*' in assignment

    Posted 3 Feb 2014

    View Postjimblumberg, on 03 February 2014 - 10:16 AM, said:

    You are, remember tt is a pointer to a single int, not an array of int.

    Jim


    I thought that if I incremented an int like below, I am moving the memory location.
    For example the &int = 0x120 and if I increment it like this ++(*int) = 0x121 . Is this not the case? Each loop shows the same memory location.

    An example is provided below:

    Increment memory

    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    
    using namespace std;
    
    int main()
    {
    
         int *tt = new int;
         int *p = new int;
         int mint = 665;
         tt = &mint;
    
     for (int i = 0; i < 10;i++)
        {
            ++(*tt);   //I thought this would increment the memory location of tt
     
          cout << &tt << endl; // I am displaying the memory location of
                              //   tt
    
        }
    }
    
    
  4. In Topic: error: cannot convert 'int**' to 'int*' in assignment

    Posted 3 Feb 2014

    View Postjimblumberg, on 03 February 2014 - 09:20 AM, said:

    It would help if you explain exactly what you think is happening in your program, line by line.

    Since both p and tt are pointers you don't need to dereference tt to point p to the address of tt.

    I hope you realize your program is modifying the value of tt, not the address of tt in your loop.

    Jim


    I can see it now. Silly mistake. I've dereferenced a pointer when I didn't need to. OK, so if I skip this step I still
    get the same memory location with each loop. How do I show the memory location of tt as it progresses in each loop. &t I mean? Thanks


    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    
    using namespace std;
    
    int main()
    {
    
         int *tt = new int;
         int *p = new int;
         int mint = 665;
         tt = &mint;
    
     for (int i = 0; i < 10;i++)
        {
            ++(*tt);   //I thought this would increment the memory location of tt
            p= &tt; // I get the error here?    .... transferring the memory location from tt to p though I see
                                                //what you mean.  They are both pointers so there is no need to dereference.
                                                // It is a pointless step then.  
            cout << &p << endl; I am displaying the memory location of p.
    
        }
    }
    
  5. In Topic: Extracting Integers from a file?

    Posted 23 Nov 2013

    Thanks, I've been looking for something like this.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

tomadom hasn't added any friends yet.

Comments

tomadom has no profile comments yet. Why not say hello?