×
BLUE
c++-Creating Pointers


c++-Creating Pointers
  12 April 2021
Read more Like this Post.
Example explained Create a pointer variable with the name ptr, that points to a string variable, by using the asterisk sign * (string* ptr). Note that the type of the pointer has to match the type of the variable you're working with. Use the
#include 
using namespace std;

main(){
    int x = 5;
    int* p;
    p = &x;
    cout << p << endl;
    cout << ++p;
    cout << "chars" << endl;
    float a = 0.1;
    float* b = &a;
    cout << b++ << endl;
    cout << b << endl;

}
A pointer however, is a variable that stores the memory address as its value. A pointer variable points to a data type (like int or string) of the same type, and is created with the * operator. The address of the variable you're working with is assigned to the pointer:
Related Post's

CPP   cpp functions   function   classes   loops  
Not Loaded Zohaib Jozvi
0 12 April 2021
Read Latest Post.
Read other post.