Horje
pointer Code Example
pointer
Variable is used to store value
Pointer is used to store addresss of value
pointer
#include <iostream>
// by using increment sign we know whole array
int main()
{
	using namespace std;
	int ar[] = { 1,2,3,4,5,6,7,8,9,10 };
	for (int m : ar)
	{
		cout << m << endl;
	}
	return 0;
}
pointer
As discussed earlier, 'p' is a pointer to 'a'. Since 'a' has a value of 10, so '*p' is 10. 'p' stores the address of a. So the output p = 0xffff377c implies that 0xffff377c is the address of 'a'. '&p' represents the address of 'p' which is 0xffff3778. Now, '*&p' is the value of '&p' and the value of '&p' is the address of 'a'. So, it is 0xffff377c.
pointer
p = 0xffff377c
*p = 10
&p = 0xffff3778
*&p = 0xffff377c
pointer
#include <iostream>
using namespace std;
int main()
{
	int* p;
	p = new int;
	if (p)
	{
		cout << "success";
	}
	return 0;
}




Cpp

Related
c++ power of two Code Example c++ power of two Code Example
or in c++ Code Example or in c++ Code Example
and c++ Code Example and c++ Code Example
Linked list in c++ Code Example Linked list in c++ Code Example
auto& in c++ Code Example auto& in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9