typedef in C Part-1 | C Language Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome to nourish technologies this is cinemas in this session so we are going to discuss about a user defined data type in C language so what is the user defined data type that is type def type def so actually this is a keyword this is a keyword in C language is used to create synonyms so what is a synonym so another meaning nothing but duplicate identity or a alias name we can call okay so using type def we can create alias names to the identities nothing but two data types which are available so what all the data types available in a application write that we can access with the help of alias names also with the help of duplicate names also okay how can we create and on see here it is whenever you declare here it is suppose one data type is there data type and here it is alias name we are writing alias name means a duplicate name just considered alias name and next before the data type we have to write a type def declaration we have to write type def declaration so what is that see for example so this is the syntax syntax and this is example type def type def in teaser suppose int and followed by we are writing one identity my in my in suppose if you are not writing this only int and followed by identifier means it is just working like a variable so variable is of type int easy so it holds integer data it holds integer data but here in front of data type if you place the type def declaration right if you place type def declaration from now it is working like alias name two integer datatype so this is original identity original identity of a data type and this is duplicate identity this is duplicate identity one is original identity second one is a duplicate identity sir will the reserve any space in the program know these identities shall not occupy any memory in the application and one more thing we can declare these variables either locally or globally inside a particular method or block if you write this statement my in belongs to that particular method or block only from outside of that block you can't use suppose if you declare globally as a global variable then you can access anywhere in the program so these synonyms for these alias names can be either global or local right next one sir are the permanent no once the control come out of the method or once the control come out of the program all these local identities and global identities will be deleted will be deleted okay these are not permanent and these will not occupy any memory in the application right so this is what we call a type def declaration we'll see some of the examples where we use exactly okay see one example suppose in the main method in the main method I am declaring one variable suppose using type def type def int my underscore in now I am declaring two variables suppose here it is in a comma B and C also suppose we are taking here a value is a 10 or you can initialize directly simply simply a equals to 10 B equals to 20 and C we are adding C equals to a plus B and we are printing the C value some value so we are printing some value we are printing so what it will print so 10 plus 20 30 it will print instead of using this int in place of int we can use my underscore int also here we can use my underscore int also it is also allowed okay so this is variables declaration type def declaration it is a simple example because my int is the alias name to integer type so here we are declaring variables declaring variables with the help of alias names only okay we will see one more example this is we are using primitive types and in the next program so we use a derived data types like array okay see so now we are using it is a derived data types to represent type def okay for example in the main function I want to declare an array here just integer type array in teaser so array name we are taking a are are the size is a 5 this consider so what is the meaning of this one ARR is an array of sizes of five which is holding integer data but now in front of integer so we are writing type def in front of integer we are writing type def then what will happen from now ARR is working like a template template means a predefined structure right it is a template alias name of integer array with the size is a 5 so clearly to understand look at this a RR x this is variable declaration here directly we can store 5 elements 10 20 30 40 50 so what type of data integers are where you specified the integer type and where you specified the size is not there more clearly in place of ARR you can write array now it is very clear now it is very clear array we are declaring array variable but sir-- varies the square brackets where you are representing the size and where is the datatype here in the template you are representing here in the template you are representing suppose here it is sizes of 5 and type is a integer type so this array is also holding this arrays also holding X is a variable array variable of type is a integer if the size is a 5 so that is why it is allowed to store 5 elements then how can we print here it is printf printf array elements are printf array elements are here it is using for loop but here we need to declare integer type variable we need to declare integer variable I to repeat the loop index starts with a 0 I is less than 5 I plus plus printf % is d X of I it is allowed to print like this I value starts with a 0 I is less than 5 I plus plus ok and here we are printing so array elements but here it is in the Declaration of X in the Declaration of X so here it is we are not specifying what type of data you are storing and we are not specifying the size because already we specified right here it is in the creation of or in the definition of alias name more clearly we can call it as a template okay so this is how the declaration write mean type def declaration to derive data types okay and what are the advantages of type def declarations right and how can we apply all these things to user defined data types so that we will see in the next session okay for more videos please subscribe to nourish 80 channel thank you
Info
Channel: Naresh i Technologies
Views: 170,279
Rating: 4.8815117 out of 5
Keywords: C Language, Recursion in C, Srinivas, Naresh IT, Hands on C Language Training, C Language Demo, Online C Language Training, C Language Tutorial Videos, C Language Overview, C Language Interview Questions
Id: KcFuHLp85Jg
Channel Id: undefined
Length: 10min 33sec (633 seconds)
Published: Sat Oct 29 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.