22
Oct

C Programming Tutorial DAY 10|Pointer|Access Pointer Variable|pointers with arrays| To Functions


Welcome to code developer Day 10 Chapter ten point us So today we studied your board what is mean by pointer is and ye can be used and how To declare and accessing a pointer variable explained pointer increments or agreements explain the uses of pointers with arrays explain how pointer to function can be used Explain pointers to structures can be used So what is pointer it’s a definition so point is a variable which stores the address of the another variable declaration of pointers index So it is a data type. It is a pointer variable So astrick refers to pointer Variable so example integer is a data type then a string is refers to pointer. Wait It is a PTR is a variable of pointer So accessing data to the pointer variable how to access in the data table so I am person is refers to address of the variable it hold the Pointer variable it hold the address of another one variable Example integer has 2 K is a pointer variable. So B’s Ordinary variable so B equal to 10 is a value ampersand B the B has an individual address ambisonics refers to address of B in these address is stored into a Variable that is pointer is a variable. So another one example India a strict P a Strict P is refers to a pointer variable already have to know So quantity equal to Chandi, so it is a variable this is I am person quantity The address is stored into P variable Under run example. So VL equal to that is a variable equal 200 Amberson v-a-l-e is refers to display the address. So it is a format of Personalized you he’s a format of address then pause lady Is he farmer dove in danger of presentations? So ven? so VL means the data The output is hundred then personal ad D comma as tree as well as ampersand Y so e 2 refers to the address of the value that is the answer is hundred Way our pointer used to return more than one value from a function to pass erase and Springs more conveniently from one function to another to my new plates Erase mony amore easily to moving points to them instead of moving the array themselves To allocate memory and access it dynamic memory allocations to Create complex data structures such as linked lists where one data structure must contain references to other data structures Advantages of pointer a pointer enabled as to access a variable that is defined outside the function Second point pointers are more efficient in handling the data tables pointers Lucy reduce the length and complexity of a program They increase the execution speed The use of your pointer are a true character strings results in saving of data storage space in memory The function Poynter can be used to call a function The point is array give you a convenient method for storing streets Many of these see built-in functions that work with string use pointers It provides a way of accessing a variable without referring to the variable directly Example say example It is a n equal to 10 is ordinary variable. It is a point of the presentation it hold the address The PTR is a pointer variable. So it hold the address of Y n variable So the print of in these answer n value so 10 though so this value it represent the address of in variable then PTR is Represent the address then astrick PTR is directly pointing to the value. So the answer is 10 Another one example, so Character name of size so size is 10 then characteristic I so as it refers to the pointer. So character pointer So enter your name so get us of maybe are you the input the input is stored into name variable? the address of name variable are stored into I variable now printing your name is so Astrick, I not equal to null so Astra guy is Directly pointing to the data from the knee. So each time the loop is executed With a single character so astok I So it is moving to another one another one Character up to the end of the character So up to the I not equal to now slash 0 is mean by null character The pointer is automatic to moving to another one another one characters Explain how the variable can access by pointer here a String B is a pointer variable. First of all enter the radius of the circle. We are getting the input for the Input is stored into our variable. So a equal to 3 point 1 4 into R into R So these answer? The answer is stored into a variable. The address is stored into B. That is pointer variable so that gay he’s Directly printing the data. He’s already We know the calculation the 3.14 into R into R in these data is directly printed in floating forward Then I am Pozniak. He is printing the address of a variable So B Is displayed the address from a variable When astrick B is directly pointing to the data So as to refers to directly pointing to it data Honorabie is refers to the address of the variable. That is a variable So next one pointer ultimately Addition and subtraction are the only operation that can be performed on pointers Take a look at the following example Here Amberson be a Variable in this value is stored into PTR variable if you are using BA are equal to 500 it is only for moving the address if you are using ashtray PTR underscore BA plus plus means the value is incremented Otherwise, the address is incremented in these example. We are moving the next address Take a look at the following the redzone let Variable be an increment type variable having the value 500 and stored at the address That is an example of thousands his address example orders then PTR underscore Vav here Pointer variable has the value Thousand stored in it since India are two bytes wrong after the expression pointer variable plus plus that is already how I have to explain to you the pointer variable will have the values as thousand and two and Not the asana known because of dizzy integer variable so in de jure it have to occupy two pipes so that The addresses initial address is now seven means the next status is thousand and true Example of memory allocations so pointer increment process example first integer pointer variable and PTR equal to ETA Memorial allocations We are allocating the space. The space is stored into PT our variable the space is Only for we are give the input of the integer value So PTR equal to hundred astrick PT or equal to hundred means in these Data is directly stored into the point of variable. He said value 100 is a value so pitch here it refers the address of Pointer variable firstly you is a format of address Here PTR it is directly pointing to the data That is the answer of hundred Then PTR + + already before how to I have to explain to you. So PTR plus plus means Just we are increment the address as tricky refers to pointer that is The increment the value in these external PTR plus phosphines increments With the two bites already example already you how do you the Address the starting address thousand means the next address thousand and so print off a strict meteor The answer is 101 then free FPGA Just we are remove the spaces memory allocated spaces from the PTR pointer variable And hints each time a pointer is incremented its Points to the memory locations of the next element of its base type each time It is degree minded. It points to the locations of the previous element. All other pointers will increase or degrees Depending of the length of the data type they are finding through Two points can be compared in your national Expression provided both the pointers are pointing to variables of the same type These are another one example increment and agreement operator using pointers Say example continuous The point is special operators so am person is refers to or attends the memory address of the operand a string it is a complement of Ambersons it returns the value Combined in the memory locations pointed to by the point of variables value Design of an example write AC program to find the length of the string using PT earth first of all, we are getting the input in these input is directly to the stored into pointer variable That is a strict text Here put character is used to for to display the character elastic PTR not equal to null The pointer always pointing to the first character. It is our automatic to moving the next next Address so that a stick PT plus bus, so let me equal to PT Minus a stick text for we how to calculate the length of a string after that we are display Elian it’s a total number of character Another on example add two numbers using pointers Thank you

Tags: , , , , , , , , , ,

There are no comments yet

Why not be the first

Leave a Reply

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