This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/Exercises/C13/ex2.c

28 lines
524 B
C
Raw Normal View History

2023-10-06 14:24:41 +00:00
#include <stdio.h>
#include <stdlib.h>
int main (void )
{
// Declare a in integer
int c,d;
// Declar and integer pointer
int *ptrC;
// Some assgnments
c = 10; // C now contains the value 10
ptrC = &c; // ptrC now 'Points' to c
*ptrC = 20;
// Get the value of c via the pointer and store in d
d = *ptrC; // d now contains 10
printf ("The value in d is %d\n", d);
// Change the value of c via the pointer ptrC
*ptrC = 1; //c now contains 1
printf ("The value in c is %d\n", c);
return 0; // exit
}