The C programming speech provides you with a statistics type called a pointer. A pointer "points" to another erratic in your software code. Pointers are assigned the address space of a C variable. To appreciate pointer, you need to practice defining and transfer them to C variables. Using a pointer example, you can follow the code and see how the variable's value changes by manipulate the information in the pointer.
Instructions
Step1
Define some C variables. In this case, two variables are used to track the pointer values. The next code is how you describe variables in C:
int newValue = 0;
int oldValue = 0;
Notice is this instance that the assessment of both variables is zero. This is significant to note later in your code.
Step2
Create your cursor. A pointer variable is distinct with the asterisk prefix. The following code define a indicator in C:
int *ptr;
Step3
Assign the pointer to a variable. A baton is assigned the attend to of a variable. You allocate the address space of a pointer with the "&" prefix. The following code assigns a pointer to the address legroom of the "oldValue" variable:



Reply With Quote
Copyright Techfuels
Bookmarks