All pastes #501129 Raw Edit

learning pointers

public c v1 · immutable
·published 2007-05-21 21:44 UTC
rendered paste body
/* learning pointers */#include <stdio.h>void swap (char *x, char *y);		//swap takes 2 pointers to charsint main ( void ){	char a =  'a';	char b =  'b';	swap(&a, &b);			//pass the address of both chars to swap 	printf("%c, %c\n", a, b);	//(effectively making them the equiv of a pointer)	return 0;}void swap (char *x, char *y){	char temp;		temp = *x; 			// temp is assigned the value in which x points to	*x = *y;   			// the value x points to is assigned to the value y points to	*y = temp; 			// the value y points to is assigned the value of temp}