Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

assign value to a pointer

int main(){
  int arr[2];
  int* ptr = arr;
  // to assign value to a pointer we can use two methods :
  
  // Pointer Subscript Notation
  ptr[0] = 1337;								// the first element
  
  // Pointer Offset Notation
  *(ptr + 1) = 1338;							// the second element
  return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #assign #pointer
ADD COMMENT
Topic
Name
5+9 =