Search

6.7 — Introduction to pointers

In lesson 1.3 -- a first look at variables, we noted that a variable is a name for a piece of memory that holds a value. When our program instantiates a variable, a free memory address is automatically assigned to the variable, and any value we assign to the variable is stored in this memory address.

For example:

When this statement is executed by the CPU, a piece of memory from RAM will be set aside. For the sake of example, let’s say that the variable x is assigned memory location 140. Whenever the program sees the variable x in an expression or statement, it knows that it should look in memory location 140 to get the value.

The nice thing about variables is that we don’t need to worry about what specific memory address is assigned. We just refer to the variable by its given identifier, and the compiler translates this name into the appropriately assigned memory address.

However, this approach has some limitations, which we’ll discuss in this and future lessons.

The address-of operator (&)

The address-of operator (&) allows us to see what memory address is assigned to a variable. This is pretty straightforward:

On the author’s machine, the above program printed:

5
0027FEA0

Note: Although the address-of operator looks just like the bitwise-and operator, you can distinguish them because the address-of operator is unary, whereas the bitwise-and operator is binary.

The dereference operator (*)

Getting the address of a variable isn’t very useful by itself.

The dereference operator (*) allows us to get the value at a particular address:

On the author’s machine, the above program printed:

5
0027FEA0
5

Note: Although the dereference operator looks just like the multiplication operator, you can distinguish them because the dereference operator is unary, whereas the multiplication operator is binary.

Pointers

With the address-of operator and dereference operators now added to our toolkits, we can now talk about pointers. A pointer is a variable that holds a memory address as its value.

Pointers are typically seen as one of the most confusing parts of the C++ language, but they’re surprisingly simple when explained properly.

Declaring a pointer

Pointer variables are declared just like normal variables, only with an asterisk between the data type and the variable name.

Syntactically, C++ will accept the asterisk next to the data type, next to the variable name, or even in the middle. Note that this asterisk is not a dereference. It is part of the pointer declaration syntax.

However, when declaring multiple pointer variables, the asterisk has to be included with each variable. It’s easy to forget to do this if you get used to attaching the asterisk to the type instead of the variable name!

For this reason, when declaring a variable, we recommend putting the asterisk next to the variable name.

Best practice: When declaring a pointer variable, put the asterisk next to the variable name.

However, when returning a pointer from a function, it’s clearer to put the asterisk next to the return type:

This makes it clear that the function is returning a value of type int* and not an int.

Best practice: When declaring a function, put the asterisk of a pointer return value next to the type.

Just like normal variables, pointers are not initialized when declared. If not initialized with a value, they will contain garbage.

Assigning a value to a pointer

Since pointers only hold addresses, when we assign a value to a pointer, that value has to be an address. One of the most common things to do with pointers is have them hold the address of a different variable.

To get the address of a variable, we use the address-of operator:

Conceptually, you can think of the above snippet like this:

This is where pointers get their name from -- ptr is holding the address of variable value, so we say that ptr is “pointing to” value.

It is also easy to see using code:

On the author’s machine, this printed:

0012FF7C
0012FF7C

The type of the pointer has to match the type of the variable being pointed to:

Note that the following is also not legal:

This is because pointers can only hold addresses, and the integer literal 5 does not have a memory address. If you try this, the compiler will tell you it cannot convert an integer to an integer pointer.

C++ will also not allow you to directly assign literal memory addresses to a pointer:

The address-of operator returns a pointer

It’s worth noting that the address-of operator (&) doesn’t return the address of its operand as a literal. Instead, it returns a pointer containing the address of the operand, whose type is derived from the argument (e.g. taking the address of an int will return the address in an int pointer).

We can see this in the following example:

On Visual Studio 2013, this printed:

int *

(With gcc, this prints “pi” (pointer to integer) instead).

This pointer can then be printed or assigned as desired.

Dereferencing pointers

Once we have a pointer variable pointing at something, the other common thing to do with it is dereference the pointer to get the value of what it’s pointing at. A dereferenced pointer evaluates to the contents of the address it is pointing to.

The above program prints:

0012FF7C
5
0012FF7C
5

This is why pointers must have a type. Without a type, a pointer wouldn’t know how to interpret the contents it was pointing to when it was dereferenced. It’s also why the type of the pointer and the variable address it’s being assigned to must match. If they did not, when the pointer was dereferenced, it would misinterpret the bits as a different type.

Once assigned, a pointer value can be reassigned to another value:

When the address of variable value is assigned to ptr, the following are true:

  • ptr is the same as &value
  • *ptr is treated the same as value

Because *ptr is treated the same as value, you can assign values to it just as if it were variable value! The following program prints 7:

A warning about dereferencing invalid pointers

Pointers in C++ are inherently unsafe, and improper pointer usage is one of the best ways to crash your application.

When a pointer is dereferenced, the application attempts to go to the memory location that is stored in the pointer and retrieve the contents of memory. For security reasons, modern operating systems sandbox applications to prevent them from improperly interacting with other applications, and to protect the stability of the operating system itself. If an application tries to access a memory location not allocated to it by the operating system, the operating system may shut down the application.

The following program illustrates this, and will probably crash when you run it (go ahead, try it, you won’t harm your machine):

The size of pointers

The size of a pointer is dependent upon the architecture the executable is compiled for -- a 32-bit executable uses 32-bit memory addresses -- consequently, a pointer on a 32-bit machine is 32 bits (4 bytes). With a 64-bit executable, a pointer would be 64 bits (8 bytes). Note that this is true regardless of what is being pointed to:

As you can see, the size of the pointer is always the same. This is because a pointer is just a memory address, and the number of bits needed to access a memory address on a given machine is always constant.

What good are pointers?

At this point, pointers may seem a little silly, academic, or obtuse. Why use a pointer if we can just use the original variable?

It turns out that pointers are useful in many different cases:

1) Arrays are implemented using pointers. Pointers can be used to iterate through an array (as an alternative to array indices) (covered in lesson 6.8).
2) They are the only way you can dynamically allocate memory in C++ (covered in lesson 6.9). This is by far the most common use case for pointers.
3) They can be used to pass a large amount of data to a function in a way that doesn’t involve copying the data, which is inefficient (covered in lesson 7.4)
4) They can be used to pass a function as a parameter to another function (covered in lesson 7.8).
5) They can be used to achieve polymorphism when dealing with inheritance (covered in lesson 12.1).
6) They can be used to have one struct/class point at another struct/class, to form a chain. This is useful in some more advanced data structures, such as linked lists and trees.

So there are actually a surprising number of uses for pointers. But don’t worry if you don’t understand what most of these are yet. Now that you understand what pointers are at a basic level, we can start taking an in-depth look at the various cases in which they’re useful, which we’ll do in subsequent lessons.

Conclusion

Pointers are variables that hold a memory address. They can be dereferenced using the dereference operator (*) to retrieve the value at the address they are holding. Dereferencing a garbage pointer may crash your application.

Best practice: When declaring a pointer variable, put the asterisk next to the variable name.
Best practice: When declaring a function, put the asterisk of a pointer return value next to the type.

Quiz

1) What values does this program print? Assume a short is 2 bytes, and a 32-bit machine.

Show Solution

2) What’s wrong with this snippet of code?

Show Solution

6.7a -- Null pointers
Index
6.6 -- C-style strings

133 comments to 6.7 — Introduction to pointers

  • Gurjeet

    Hey Alex , thanks for these well explained tutorials. I have a question. As the pointer’s data type in the above examples tells us that it can only contain integers that is the value can only be an integer but in actual the value also contains a character . So how is it possible.

    • Alex

      > As the pointer’s data type in the above examples tells us that it can only contain integers that is the value can only be an integer but in actual the value also contains a character

      Where does it contain a character?

  • Nguyen

    Hi Alex,

    I really like how you define "variable".  It is so well explained & described.  

    I’ve read how variables are defined in some other books, they are all explained in general that "Variables are symbolic names that represent locations in the computer’s RAM.  When information is stored in a variable, it is actually stored in RAM".  Ok, then what? Something I still felt missing until I read your example "For the sake of example, let’s say that the variable x is assigned memory location 140. Whenever the program sees the variable x in an expression or statement, it knows that it should look in memory location 140 to get the value."  With your example, I now understand from WHERE the program gets the value when it sees a variable.

    Thanks,

  • thaki

    #include <iostream>

    void foo(int *&p)
    {
    }

    int main()
    {
        int *p; // Create an uninitialized pointer (that points to garbage)
        foo(p); // Trick compiler into thinking we’re going to assign this a valid value
            
        std::cout << *p; // Dereference the garbage pointer

        return 0;
    }
    Here we are passing pointer variable to the function foo()…
    But why does the function foo()’s parameter looks like *&p? what does it mean?
    My opinion is-
    As we’re giving pointer as function argument, foo()’s parameter’s type should also be a pointer. Correct me if I’am wrong…

    • Alex

      The parameter is a reference to a pointer (the ampersand in the parameter means “reference”). We haven’t covered references yet, so don’t worry too much about it at this point. We’re just using it to trick the compiler into letting us do something that it might otherwise complain about.

  • heyjuhua

    Hi, Alex, may I ask are you going to teach us
    6) They can be used to have one struct/class point at another struct/class, to form a chain. This is useful in some more advanced data structures, such as linked lists and trees.

    this kind of knowledge? if not do you have any recommendation of a book or good resource to learn about because I think the way you explain the knowledge is very easy to follow and understand! thanks

    • Alex

      I don’t have anything on advanced data structures at this point. I’d like to add some lessons at some point, but it probably won’t happen soon. I don’t know of any good books that make these things easy to learn either -- which is why I’d like to write it.

  • muki

    could you Please explain in details below code :

    #include <iostream>

    void foo(int *&p)
    {
    }

    int main()
    {
        int *p; // Create an uninitialized pointer (that points to garbage)
        foo(p); // Trick compiler into thinking we’re going to assign this a valid value
            
        std::cout << *p; // Dereference the garbage pointer

        return 0;
    }

    • Alex

      We’re passing pointer p by reference to function foo() (we haven’t covered references yet at this point). Even though we never do anything with p inside function foo(), this is often enough to work around the compiler’s basic uninitialized variable detection.

  • Nguyen

    Hi Alex,

    The address-of operator (&)

    The address-of operator (&) allows us to see what memory address is assigned to a variable. This is pretty straightforward:

    #include <iostream>

    int main()
    {
        int x = 5;
        std::cout << x << ‘\n’; // print the value of variable x
        std::cout << &x << ‘\n’; // print the memory address of variable x

        return 0;
    }

    =================================================
    4 bytes of memory is reserved for the variable x.  Each byte of memory has a unique address.  Let’s name these addresses as address0, address1, address2, & address3.  How do I know which address should be printed?

    • Alex

      The lowest address of a multi-byte variable is returned. So in your example, address0 would be returned (assuming address 0, 1, 2, and 3 are sequential).

  • Jack

    Hi Alex,

    Any chance to recommend some good pointer practice website in c++? Love your quiz and please keep up the good work!

  • Nguyen

    Hi Alex,

    I have a very silly question.  Are memory address & memory location the same?

    Thanks, Have a great day

  • Nguyen

    Hi Alex,

    Quiz 1.

    *ptr = 9; //Line 12
    Is it Ok if I assign otherValue to *ptr (*ptr = otherValue)?

    Quiz 2.

    *ptr = &value; // assign address of value to ptr
    Anything wrong if I just assign value instead of &value to *prt (*ptr = value;)

    Thanks, Have a great day.

    • Alex

      1) Yes.
      2) It depends. ptr = &value sets ptr to point at the address of value. *ptr = value means “copy value into whatever address ptr is pointing at”. If ptr is already pointing at value, then this is the equivalent of “value = value”, which is useless.

      • Nguyen

        This means I can assign a variable to a dereferenced pointer.  That variable must be initialized with a value; otherwise, the dereferenced pointer is a garbage.  Please let me know if I am wrong (sorry for my poor English)

        Example 1:

        int x = 1;
        int y = 2;

        int *ptr = &x;

        *ptr = y;
        std::cout << *ptr; // prints 2

        ==============================

        Example 2:

        int x = 1;
        int y; // y is not initialized

        int *ptr = &x;

        *ptr = y;
        std::cout << *ptr; // Dereference the garbage pointer

        • Alex

          Right. A dereference pointer acts just like a normal variable (assuming the dereference is successful). Assigning a garbage value to a dereferenced pointer has the same effect as assigning a garbage value to a normal variable.

  • lnm

    Hey, Alex!
    Can c++ swap the value of 2 pointer or use std::sort to sort linked lists ?
    If yes, can you illustrate it for me.
    Thanks.

    • Alex

      Yes, you can swap the value of two pointers in two ways:
      1) using std::swap from the standard library
      2) by writing your own function, and passing your pointers by reference (this is covered in lesson 7.4)

      You can’t sort a linked list using std::sort because std::sort requires the class being sorted has a random access iterator, and std::list only has bidirectional iterators. However, std::list have their own sort method as part of the class, so you can use that.

  • Mr C++

    This Prints :-
    0x60ff1c 0x60ff18

    This Prints  :-
    0x60ff18

    Why does "ptr" prints 2 different memory addresses while pointing to the same variable?
    And Also, why &ptr in the 1st case == ptr in the 2nd case?
    (I know that &ptr prints the memory address of the pointer(not the variable it is pointing to).

    • Alex

      No idea. Maybe your compiler is optimizing the code differently in each case.

        • Sivasankar

          Why does "ptr" prints 2 different memory addresses while pointing to the same variable?
          Because you are printing the value of the pointer variable ptr(i.e. the address of variable ‘x’) and the address of pointer itself(i.e. &ptr). Obviously they are 2 different addresses and will be different.

          why &ptr in the 1st case == ptr in the 2nd case?
          There will be no logical connection between the addresses of variables in different runs. In the first case, compiler assigned memory address ‘0x60ff18’ to ptr. Then it got released(i.e. it is available for use by other programs) at the end of the main in first run. In the second case, compiler reused the address ‘0x60ff18’ for variable ‘x’ which is free at that time.

          • Mr C++

            I think you misunderstood my question !
            Even if I do :-

            It prints the same memory address for both !
            I hope you must have understood by now !
            Thank Anyway 🙂

            • Sivasankar

              Hi. I understood your code. It should print different addresses. Here, remember that ptr is also a variable like x is a variable. Every variable has its own address. Syntactically,

              &<variable name> = address of <variable name>
              <variable name> = value held by the <variable name>

              In above line, as per type and definition, ‘ptr’ refers to the address held by ‘ptr’ which is the address of variable ‘x’.
              we can see that as below

              ptr = value of variable ptr = address of x = &x
              *ptr = value at the address held by ptr = value at &x = 5
              x = value of variable ‘x’ = 5
              &x = address of variable ‘x’
              *x = invalid statement

              ‘&ptr’ = address of variable ‘ptr’.

              Even though ‘ptr’ is pointing to ‘x’, ‘ptr’ should have its own address. so &x != &ptr implies ptr != &ptr

              • Mr C++

                I knew this man !
                I was just asking Alex that why is ptr and &ptr printing same memory address. That was my only Question.
                Thanks For The Help Anyways 🙂

                • Sivasankar

                  Your concern might be why ‘&ptr’ in the 1st output (0x60ff18) is same as ‘ptr’ in the 2nd output (0x60ff18). Is that your question? If so, please check my comments below

                  They are 2 different runs of the program. This is how it might happened in step by step,

                  1. In the 1st run, compiler allocated 0x60ff1c to int variable ‘x’ and 0x60ff18 to pointer variable ‘ptr’.
                  2. So below line printed "0x60ff1c 0x60ff18"

                  3. While exiting the main function here, both the int variable ‘x’ and the pointer variable ‘ptr’ are automatically destroyed. So their addresses (0x60ff1c and 0x60ff18) are not allocated anymore and free for reuse.
                  4. In 2nd time, compiler reused the address 0x60ff18  and allocated to variable ‘x’ (Here, the same address 0x60ff18 was once allocated to ‘ptr’ at step 1 in 1st run and then got released run at step 3 in 1st run) and some other free address to pointer variable ‘ptr’.
                  5. So below line printed "0x60ff18"

                  Ignore it if it is not your question

  • Said

    Finally, I was wondering how you could pass variables in to a function like switch and have it violate scope. I tried to do this back in lesson 6.4 but I couldn’t figure it out but now…

    • Said

      Never mind, just got to references these are not pointers. Was wondering why this worked exactly because the & operator gives the the address and doesn’t assign it.

  • Kris

    Hi, nice tutorial. I would just like to point out (with pointer of course 🙂 ) that maybe you should comment how these two lines which are identical at first are really not identical at all. It got me a bit confused, but then I remembered that * can be anywhere between type and actual name of pointer so my conclusion is that this line "2." can/must be observed as line "2′.". The lines I’m talking about are:

    So maybe You should just point out that while declaring pointer this * is part of cast and that is is actually (in logical sense) something like this:

    I hope You understood what I was trying to say and if I am wrong please correct me.

    Thanks & best regards!
    Kris

    • Alex

      I get what you mean, and I can see why this is confusing. I hope you don’t mind, but I turned your example into a quiz question, complete with a detailed explanation. Hopefully this will help others who run across a similar confusion.

  • James Ray

    "This is because pointers can only hold addresses, and the integer literal 5 does not have a memory address." Should you say: "the integer literal 5 is not a memory address." I am surprised if it doesn’t have a memory address. How would the CPU, which can only read 1s and 0s (or electrical binary states), be able to know what 5 represents, if it isn’t stored in memory with the compiler? I suspect that this semi-rhetorical question is not fully correct, that’s just where my understanding is. I guess this may be beyond the scope of C++ as well, but it is probably more important to have at least a basic, high-level understanding of how CPUs, memory and computers work before learning a programming language.

    http://homepage.cs.uri.edu/faculty/wolfe/book/Readings/Reading04.htm
    http://www.computerhope.com/jargon/m/memory.htm

    • Alex

      The literal 5 both doesn’t have an assigned memory address, nor is it a memory address, so both of our statements are true. While it’s true that 5 will get turned into a series of bits that will go into memory somewhere (as every instruction and piece of data has to be in memory to be executed), that memory is transient. Generally, when we say something “has a memory address”, we mean a particular spot of memory has been reserved for it (basically, it’s an l-value). With a value like 5, that’s not true -- it’s just a transient value. You can’t ask 5 for its memory address (like you can with a variable) and get an address back.

      • James Ray

        Yeah, that makes sense. The value of 5, being fixed, can’t be an l-value, so it doesn’t and shouldn’t have a memory address.

  • Rohit

    This code is printing 8 instead of 4, why?

    char *chPtr; // chars are 1 byte
    int *iPtr; // ints are usually 4 bytes
    struct Something
    {
        int nX, nY, nZ;
    };
    Something *somethingPtr; // Something is probably 12 bytes

    std::cout << sizeof(chPtr) << ‘\n’; // prints 4
    std::cout << sizeof(iPtr) << ‘\n’; // prints 4
    std::cout << sizeof(somethingPtr) << ‘\n’; // prints 4

    • Rohit

      Got the answer, no need to reply.

    • Alex

      Pointers hold memory addresses. So the size of a pointer will always be equal to the size of a memory address on your system. On a 32-bit operating system, that will generally be 32 bits (4 bytes), which is why you’re seeing all of these print 4. On a 64-bit operating system, this will generally be 64 bits (8 bytes).

  • Rohit

    Hi Alex!
    Didn’t get this code. Why you used ptr = &value instead of *ptr = &value?
    int value1 = 5;
    int value2 = 7;

    int *ptr;

    ptr = &value1; // ptr points to value1
    std::cout << *ptr; // prints 5

    ptr = &value2; // ptr now points to value2
    std::cout << *ptr; // prints 7

    • Alex

      Remember, pointers hold addresses. So when we set a pointer’s value, we need to give it an address. We can get the address of a normal variable using &.

      “ptr = &value1” means “get value1’s address and assign it to ptr”, which makes sense since pointers hold addresses.

      Dereferencing a pointer (via *) means “get the value that the pointer is pointing to”.

      “*ptr = &value1” means “get value1’s address and assign it to the value that ptr is pointing to”. ptr is pointing to an integer, so *ptr refers to the integer’s value. It doesn’t make sense to assign the address of value1 to an integer value.

  • Matheus

    What this piece of code means?

    Is &ptr returning the address of the pointer variable? Pointers are memory address that allocate other memory address (which are pointers too)?

    • Alex

      &ptr would return the address of ptr. Pointers aren’t memory addresses, nor do they allocate other memory addresses in and of themselves.

      Pointers are essentially normal variable that hold addresses instead of normal values. Those addresses can be the addresses of other variables, or to dynamically allocated memory.

  • Elithrion

    I tried your "dereference an uninitialized pointer" example with MinGW (from inside Eclipse for what that’s worth), and was disappointed to find that it didn’t crash - instead it output a consistent (though garbage) value on every run. Not only that, but it also compiled without the foo(…) function trick with only a warning.

    It took 3-6 iterations through my loop (consistent number for one build, different between slightly different builds) before it finally started behaving itself and crashing as it should:

    Also, this:

    Prints the same number over and over (presumably moved initialization out of loop while compiling for efficiency).

    And this:

    Prints varying numbers, usually crashing, but sometimes not (and in all cases running for many iterations unlike the array version). I’m kinda curious what the compiler is doing…

  • Paul

    Seems like you have missed "0x" in the example of assigning value to a pointer, because 0012FF7C will be interpreted like octal constant.

  • Roy

    Just a quick suggestion. I was wondering if it was possible to use uniform initialization with pointers, so I tried it and it worked. Perhaps it might be a good idea to include a remark about this in the tutorial.

  • Tyler

    Hello, first of all thanks for the great tutorial. I don’t know if you still maintain this website but I had a question that I couldn’t easily find on the web. What is the value returned when I use address-of operator on a defined pointer?

    Suppose I had the following code:

    I’m unsure what the address in the second print statement refers do. Is it possible for the memory address to have an address of itself? Or is it the address of the integer literal assigned to ptr in the form of memory address? Or is it something completely different?

    Edit: I just tried printing them out with typeid() and &ptr prints as “int * *” which I guess makes sense semantically… But conceptually I have no clue what the hell is going on lol So it does seem like the memory address has its own address, I think, but does that also explain why the two addresses (ptr and &ptr) are off by 32 bits at most? What is this… uh address of address of a pointer business?

    • Alex

      Okay, let me see if I can clarify what’s going on. Memory addresses are just memory address, there’s nothing special there.

      All variables are assigned a memory address. So when you declare int x, variable x gets a memory address (lets say address 10). When you declare int *ptr, variable ptr gets a memory address (lets say address 20).

      Now, because you’ve initialized ptr with the address of x (10), the value placed in ptr’s memory address (20) will be x’s address (10).

      So, our memory looks like this:
      Address Value Note
      10 5 int x
      20 10 int *ptr

      Now, let’s take a look at 3 different print statements:

  • Kılıçarslan

    Best explanation I have ever seen.

  • bert

    Typo:

    Pointer variables are declared just like normal variable,

    I believe you meant to type "normal variables"

  • Pascal Kangberee

    Thank a lot.  Finally understand pointers. Great job

  • Dragos

    I have something unclear here:

    the fuction has int *&p, but I tought when we use * with int we declare a pointer variable, so the name of the variable is "&p"? If not what that does mean? I hope you understand what I mean.

  • Abdul sami

    Dear Alex ,I hope you will be fine.

    I have a question about Arrays.

    If we declare an Array of any size for example

    Now  arr will become a pointer  point to the first element of arr[6].

    Now when we find the size arr  

    //Size of Array = 6

    why this is happening, the arr is an int type pointer point to the first element
    same problem in function argument

    • Alex

      arr doesn’t decay into a pointer when used with operator sizeof(), so sizeof() is able to access the array length.

      The size of the array isn’t 6, it’s 24 (6 elements * 4 bytes each).

  • abolfazl

  • Georges Theodosiou

    Mr Alex,
    Please permit me a comment: At http://www.tutorialspoint.com/cplusplus/cpp_pointers.htm , first sentence is:
    "C++ pointers are easy and fun to learn." I study c++ pointers for several days and feel that you are right on that:
    "Pointers are typically seen as one of the most confusing parts of the C++ language, but they’re surprisingly simple when explained properly.".
    I express my sincere gratitude for this sentence.

    With regards and friendship
    Georges Theodosiou

  • Prajwal

    Hey Alex,
    That was yet another great tut indeed!
    I’ve got a doubt !
    When I output an address of a number,say 5 using &value,
    This is what I get : 0x22ff44
    But above for the address of 5 ,you’ve given this : 0012FF7C

    May I know what’s the difference b/w those if you don’t mind ?

    Waiting for your reply,
    Prajwal

  • Mr Alex,
    Please permit me one more comment about address of variable’s value. When I posted massage by June 11, I was using Ubuntu. Now I use Windows and address changes when I run program again, and indeed when change variable’s type or name or value. Also new address is 4 bytes different than previous when type is "int" as you posted by June 10. So you are right on that it depends on the platform used. I have learned also this from you. Many thanks. I have to learn many from you about c++. Regards.

Leave a Comment

Put C++ code inside [code][/code] tags to use the syntax highlighter