Search
 
SCRIPT & CODE EXAMPLE
 

C

pass the pointer to the function

#include<stdio.h>

//pass the simple pointer to the function

void swapnum(int* i, int* j)
{
  	int tmp = *i;
  	*i = *j;
  	*j = temp;
}

int main()
{
  	int a = 10;
  	int b = 20;
  	swap(&a,&b);
  	printf("A is %d and B is %d
", a , b);
  	return 0;
}
Comment

Passing pointer to function

#include <stdio.h>
   
void getDoubleValue(int *F){
   *F = *F + 2;
   printf("F(Formal Parameter) = %d
", *F);
}
  
int main(){
   int A;
   printf("Enter a numbers
");
   scanf("%d", &A);
   /* Calling function using call by reference */
   getDoubleValue(&A);
   /* Any change in the value of formal parameter(F)
   will effect the value of actual parameter(A) */
   printf("A(Actual Parameter) = %d
", A);
     
   return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: remove first character from string c 
C :: merge sort code c 
C :: c round function 
C :: console log observable data 
C :: arduino millis() 
C :: nested switch case in c 
C :: how to empty string in c 
C :: armstrong number in c 
C :: c static variables 
C :: pg_restore: error: input file appears to be a text format dump. Please use psql. 
C :: how to sort assending in c 
C :: go optional parameters 
C :: initialize array in c with 0 
C :: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration] 
C :: how to read keyboard input in C 
C :: how to get input in 2d array in c 
C :: enum in c 
C :: strings in c 
C :: Write a 64-bit program in assembly that prints Hello, world in .asm 
C :: c typedef 
C :: linked list using c 
C :: print float number completely in C language 
C :: c print characters 
C :: pyinstaller hidden import tensorflow not found 
C :: c structure with pointer 
C :: binary sorting 
C :: fifo in c 
C :: declare an array 
C :: lxde automatic login 
C :: c get int inpot 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =