So we're now going to discuss the go to key word while the go to keywords allows you to do it allows
you to jump to different sections of your code.
You need to be very careful when using the go to keyword because it can be abused and lead you to bad
practices.
So what we can do is we can go out colon here.
I mean we can do a 10 0 right now what I can say is if one so if true which it will always be true by
the way go to out.
So this statement will run and then we jumped out and I am here if I do print f we are leaving.
Now if I can pull out now GCSE main that C Dash I may run that.
It says We are leaving.
So what happens is I enter this f statement and I immediately jump to this out label skipping all the
code after here.
So just to demonstrate that if I go this is never called what will happen is we enter if statement because
one is always true we go to out which will skip over all of this and go to this label here and begin
running from that.
So if we can pull out now run that all we see is we are leaving because we jump over this if we put
a zero here.
So it never gets run because zero is false.
And we we compile that JCC main dot c dash show main and then we do make this is never called is now
shown and then we are leaving.
So that is labels and the go to key.
These are quite useful in C because in C you're in charge of managing your own memory which we'll get
to soon and it's very important that if we if we were to return from here then we we would never to
allocate our memory further down here because we returned from the function.
So by using go to we can jump to the out label and then free the memory and resources here.
But more on that later.
But basically that's why go to as useful in C and C++ you should probably avoid go to but in C it is
pretty useful.