So when I was gonna discuss type deaths and type deaths allow you to create alias names for existing
types.
So for example up here if you did typedef integer might I.A. and you did that.
You could now do my uh my I.A. ABC and ABC is an inch deep because what we've said is we've said create
a type definition the type is in I.A. for integer.
The name is might in it.
So my N is now an alias of integer so we can actually do ABC equals 50 here print f percent I ABC.
And if you go to the compiler and compile that
and you run that you can see 50 output it.
So essentially we've just create an alias of I.A..
This could be along as well.
And now my in my agency is now along.
It's an alias of long.
So that is type deaths for primitive types.
So now let me show you structure type deaths if we create a new structure.
Here we go struct I know record.
And we do this.
This is our record structure or whatever and it could contain an integer.
If we want to typedef that we just put typedef at the beginning and then we just put our name by here.
So now what we can do is we can go alias ABC and notice how we don't need to do the struct keyword is
because we typedef it here.
So now we can go ABC to a quiz 50 and that should work just fine if we can pull out now you can see
that compiles fine.
So essentially by typedef in the struct we we no longer have to provide the struct keyword which is
a very useful feature.
So if you remember before I taught you about function pointers.
Well you can also typedef them so they're a little easier to understand.
So if we do typedef avoid asterisk pointer and we do this then what we can do now we can go PCR P and
then up here we can go void ABC void
and let's put a void there as well and we can now just do p equals ABC.
And now if we can pull up
that compiles fine.
So essentially what we've done here we've made a function pointer type that is for pointing to void
functions functions the return no type and take no arguments.
And we've named that alias type PCR.
So this could be anything such as void PTA void void F and C PTA.
So void function pointer and we could put that in there like that.
And now if we call P like this and we print f here hello world and we can pull up you can see Hello
worlds I put it.
So obviously defining your point is like this is pretty difficult to uh to understand.
So by typedef thing it is much more cleaner to create function pointers because now this is very clear.
We've created a function pointer that points to void functions that take no arguments.
And we've named the type void func PTA.
So whatever you want to point to a function that takes no arguments and returns void you can now just
use void func PTA.
So it's much more cleaner than writing this out every single time than writing what I've selected out
every single time.
So that's how you can typedef pointers function pointers.
So there's other forms of typedef we can do as well.
For example you can do typedef integer asterisk I.A. PCR for integer pointer.
And now if I wanted to do in it a equals fifty and I want to create integer pointer.
I could just do I could just do something like that.
I A.P. TR and then there's our variable name equals Ampersand eight.
And now I can just do a asterisk a equals fifty as usual asterisk PDR equals fifty.
As usual my mistake.
We can pull out now.
I can see that works fine.
So here we've typedef an integer points up so you can see that is a little more understandable now than
I am she I.A. asterisk PTA so there's all sorts of clever things you can do with the pre process because
type definitions are all resolved compile time not runtime.