A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Modify value stored in other variable using pointer in C
Q:

Modify value stored in other variable using pointer in C

0

Modify value stored in other variable using pointer in C

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Steps:

  • Declare a pointer of same type
  • Initialize the pointer with the other (normal variable whose value we have to modify) variable's address
  • Update the value

Program:

#include <stdio.h>

int main(void) {
	int num = 10;
	//declaring and initializing the pointer
	int *ptr = &num;

	printf("value of num: %d\n", num);
	printf("value of num: (using pointer): %d\n", *ptr);

	//updating the value
	*ptr = 20;

	printf("value of num: %d\n", num);
	printf("value of num (using pointer): %d\n", *ptr);

	return 0;
}

Output

value of num: 10 
value of num: (using pointer): 10
value of num: 20 
value of num (using pointer): 20 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now