Home / Tutorial / Programming / C / C ++ Programming Tutorials (Episode 14) Set the value of the pointer
c programming tutorial

C / C ++ Programming Tutorials (Episode 14) Set the value of the pointer

X is defined as the value of xine x. So x is an integer and x is the pointer. In other words, the value of the passenger is 10, the address of x is fff4, the value of y is fff4, y is 9001 ya. Here the addresses were conceived. The figure was tried to highlight the issue.

There are a few things to look for when determining the value. The standard variables can be set to denote the pointer variables. For example: int x, * y = & x; In this case, note that, when determining the value of the pointer, the pointer points to another variable (that is, its address will be in the pointer), it must first declare. So int * y = & x, x; If you type it, it will show errors. Because we know, the program executes one command after another. So when the program assumes the value of the program, there is no variable named ‘ViewBee’.

Because x has been declared later. So the compiler will show error here. When determining the value of the pointer variable, its data type must be kept in mind. A data type pointer can not point to variables in another data type. So the data type of pointers and pointed variables must be one. For example: int x; float * y = & x; Here the compiler error will appear, because the data types of the variables are not the same. However, it is possible to cast data on pointer values. For example: int x; char * y = (char *) & x; Here the data type of x and data is different, but data is cast when determining the value of x.

That’s the address character of x. Determining the value of the pointer by casting the data, the data type is being cast. Then of course * sign is given. But it is not fair to determine the value of the pointer by casting such data if it is not strictly neutral. The compiler does not support setting this type of value for the pointer. So it can show warnings here and sometimes trouble. The value of the pointer can not be determined without operator help. For example: int x; int * y = fff4; Here if the address of x is fff4, y, the value of the value can not be directly assigned as such, error will appear.

Pointer plays a very important role in C. Langueja. It is not possible to work with addresses other than Pointer. To create a big program, it is time to work with the address. There are many types of data structures, which are based on the concept of pointers. So learning the use of pointers is very important

About Admin

Leave a Reply

Your email address will not be published. Required fields are marked *