Pointer Declaration

Cards (10)

  • Pointer Declaration Syntax:
    dataType *pointerName;
    where:
    • dataType - is the data type of the variable the pointer will point to.
    • * - the asterisk (*) symbol is used to indicate that the variable is a pointer variable.
    • pointerName - is a unique identifier name for the pointer variable.
  • Pointer Declaration Syntax:
    dataType *pointerName;
    where:
    • dataType - is the data type of the variable the pointer will point to.
    • * - the asterisk (*) symbol is used to indicate that the variable is a pointer variable.
    • pointerName - is a unique identifier name for the pointer variable.
  • Pointer Declaration Syntax:
    dataType *pointerName;
    where:
    • dataType - is the data type of the variable the pointer will point to.
    • * - the asterisk (*) symbol is used to indicate that the variable is a pointer variable.
    • pointerName - is a unique identifier name for the pointer variable.
  • Example of Pointer Declaration
    int *ptrInt; or int* ptrInt; or int * ptrInt;
    // ptrInt can point to an integer variable
    double *ptrDouble; or double* ptrDouble;
    // ptrDouble can point to a double variable
    char *ptrChar; or char* ptrChar;
    // ptrChar can point to a character variable
    string *ptrString; or string* ptrString;
    // ptrString can point to a string variable
  • Example of Pointer Declaration
    int *ptrInt; or int* ptrInt; or int * ptrInt;
    // ptrInt can point to an integer variable
    double *ptrDouble; or double* ptrDouble;
    // ptrDouble can point to a double variable
    char *ptrChar; or char* ptrChar;
    // ptrChar can point to a character variable
    string *ptrString; or string* ptrString;
    // ptrString can point to a string variable
  • int *ptr1, ptr2; /* ptr1 is a variable that holds an address of an integer variable, while ptr2 is a simple variable that will hold data or value. */
  • int *ptr1, *ptr2; /* ptr1 and ptr2 are now variables that will hold an address of an integer variable. */
  • int *ptr1, *ptr2; /* ptr1 and ptr2 are now variables that will hold an address of an integer variable. */
  • int *ptr1, *ptr2; /* ptr1 and ptr2 are now variables that will hold an address of an integer variable. */
  • int *ptr1, ptr2; /* ptr1 is a variable that holds an address of an integer variable, while ptr2 is a simple variable that will hold data or value. */