1 00:00:00,770 --> 00:00:04,250 In this lecture, you will learn about the void function here. 2 00:00:04,250 --> 00:00:10,070 So in some cases you will need to indicate that the function does not have parameters or will not return 3 00:00:10,070 --> 00:00:10,630 a value. 4 00:00:10,640 --> 00:00:15,190 So in both cases you can use the keyword void here. 5 00:00:15,200 --> 00:00:21,880 So let's create an example application about void and then continue our lecture. 6 00:00:21,890 --> 00:00:27,740 So first void, this function will return a void here. 7 00:00:27,740 --> 00:00:36,460 So let's for example, let's print a message with this void function with void parameter here, void 8 00:00:36,470 --> 00:00:39,020 message void here. 9 00:00:39,200 --> 00:00:40,610 And then. 10 00:00:42,080 --> 00:00:42,800 Here. 11 00:00:43,400 --> 00:00:45,560 Let's print some value. 12 00:00:47,060 --> 00:00:48,240 For example. 13 00:00:48,260 --> 00:00:50,120 No inputs. 14 00:00:50,150 --> 00:00:51,110 No. 15 00:00:51,650 --> 00:00:54,800 No return value. 16 00:00:56,030 --> 00:00:57,450 Value here. 17 00:00:57,470 --> 00:01:04,760 And then, as you can see, we will not return any value from it because this is a void function and 18 00:01:04,760 --> 00:01:06,890 this will give us an error. 19 00:01:06,920 --> 00:01:11,750 So in void functions, you cannot return a value. 20 00:01:11,780 --> 00:01:21,740 So this functions in this function has only purpose is to print message on the console here as you can 21 00:01:21,740 --> 00:01:22,490 see here. 22 00:01:22,520 --> 00:01:25,760 So let's write our main function. 23 00:01:25,760 --> 00:01:33,670 So as you know, main our main functions that returns something returns integer one or zero. 24 00:01:33,710 --> 00:01:35,240 You can return ten. 25 00:01:35,690 --> 00:01:39,290 But usually that does not happen here. 26 00:01:40,220 --> 00:01:43,250 Integer void integer main function. 27 00:01:43,250 --> 00:01:50,020 And then let's call our print message a message function. 28 00:01:50,030 --> 00:01:54,110 As you can see here, print the message function. 29 00:01:54,980 --> 00:02:05,620 So now we can run our application, compile our application and run and let's see what our output is. 30 00:02:05,630 --> 00:02:07,340 So let's run our application. 31 00:02:08,100 --> 00:02:10,740 And as you can see, no inputs. 32 00:02:10,770 --> 00:02:11,920 No return value. 33 00:02:11,940 --> 00:02:17,430 So the use of void in the parameter list is optional, so you cannot use it as well. 34 00:02:17,430 --> 00:02:21,660 So an empty pair of parentheses is acceptable and preferable. 35 00:02:21,660 --> 00:02:24,600 So you don't have to do this all the time. 36 00:02:25,230 --> 00:02:27,900 It's preferable to just leave it empty. 37 00:02:27,900 --> 00:02:33,090 You don't need to add void function here, so avoid the keyboard here. 38 00:02:33,870 --> 00:02:36,240 So we will make this empty. 39 00:02:36,240 --> 00:02:43,440 As you can see here, I did this on purpose to show you why, to do this and not so. 40 00:02:44,100 --> 00:02:49,530 And this is the only way to indicate that the function returns no value other than returning void. 41 00:02:49,530 --> 00:02:55,050 So note that the void is not really a type because you cannot create a void variable. 42 00:02:55,050 --> 00:02:57,300 So it is the absence of a type. 43 00:02:57,960 --> 00:03:03,540 As you will find out in the next lecture, you can create a pointers of the type void, but you will 44 00:03:03,540 --> 00:03:10,230 not able to use the memory that such pointers point to without casting to a tied pointer. 45 00:03:10,230 --> 00:03:17,970 So to use the memory, you have to decide the type of the data that that the memory holds. 46 00:03:18,600 --> 00:03:22,290 So that's it about the void function in this lecture. 47 00:03:22,290 --> 00:03:29,370 But later on this course you will learn more about the void and void functions here. 48 00:03:29,370 --> 00:03:31,230 So see you in the next lecture.