1 00:00:00,700 --> 00:00:04,210 In this lecture you will learn about the void function here. 2 00:00:04,210 --> 00:00:10,000 So in some cases you will need to indicate that a function does not have parameters or will not return 3 00:00:10,000 --> 00:00:10,570 a value. 4 00:00:10,570 --> 00:00:15,130 So in both cases you can use the keyword void here. 5 00:00:15,130 --> 00:00:21,820 So let's create an example application about void and then continue our lecture. 6 00:00:21,820 --> 00:00:27,670 So first void, this function will return a void here. 7 00:00:27,670 --> 00:00:36,400 So let's for example, let's print a message with this void function with void parameter here, void 8 00:00:36,400 --> 00:00:39,010 message, void here. 9 00:00:39,010 --> 00:00:40,570 And then. 10 00:00:41,920 --> 00:00:42,730 Here. 11 00:00:43,240 --> 00:00:45,520 Let's print some value. 12 00:00:46,840 --> 00:00:50,050 For example, no inputs. 13 00:00:50,080 --> 00:00:51,100 No. 14 00:00:51,460 --> 00:00:52,480 No. 15 00:00:52,480 --> 00:00:54,760 Return value. 16 00:00:55,900 --> 00:00:57,370 Value here. 17 00:00:57,370 --> 00:01:04,930 And then as you can see, we will not return any value from it because this is a void function and this 18 00:01:04,930 --> 00:01:06,850 will give us an error. 19 00:01:06,850 --> 00:01:11,650 So in void functions you can not return a value. 20 00:01:11,650 --> 00:01:21,430 So this functions in this function has only purpose is to print message on the console here, as you 21 00:01:21,430 --> 00:01:22,450 can see here. 22 00:01:22,450 --> 00:01:25,660 So let's write our main function. 23 00:01:25,660 --> 00:01:33,760 So as you know, main, our main functions does returns something, returns integer 1 or 0, or you 24 00:01:33,760 --> 00:01:39,250 can return ten, but usually that does not happens here. 25 00:01:39,970 --> 00:01:43,150 Integer void integer main function. 26 00:01:43,150 --> 00:01:54,100 And then let's call our print message message function, as you can see here, print message function. 27 00:01:54,760 --> 00:02:05,560 So now we can run our application, compile our application and run and let's see what our output is. 28 00:02:05,590 --> 00:02:07,300 So let's run our application. 29 00:02:08,060 --> 00:02:11,830 And as you can see, no inputs, no return value. 30 00:02:11,840 --> 00:02:17,360 So the use of void in the parameter list is optional, so you cannot use it as well. 31 00:02:17,360 --> 00:02:21,590 So an empty pair of parentheses is acceptable and preferable. 32 00:02:21,590 --> 00:02:24,470 So you don't have to do this all the time. 33 00:02:24,980 --> 00:02:27,800 It's preferable to just leave it empty. 34 00:02:27,830 --> 00:02:33,050 You don't need to add void function here, so avoid the keyword here. 35 00:02:33,680 --> 00:02:36,170 So we will make this empty. 36 00:02:36,170 --> 00:02:43,340 As you can see here, I did this on purpose to show you why to do this and not so. 37 00:02:44,000 --> 00:02:49,430 And this is the only way to indicate that the function returns no value other than returning void. 38 00:02:49,430 --> 00:02:54,980 So note that the void is not really a type because you cannot create a void variable. 39 00:02:54,980 --> 00:02:57,320 So it is the absence of a type. 40 00:02:57,830 --> 00:03:03,470 As you will find out in the next lectures, you can create a pointer of the type void, but you will 41 00:03:03,470 --> 00:03:10,290 not able to use the memory that such pointers point to without casting to a typed pointer. 42 00:03:10,290 --> 00:03:18,030 So to use the memory, you have to decide the type of the data that that the memory holds. 43 00:03:18,450 --> 00:03:22,320 So that's it about the void function in this lecture. 44 00:03:22,320 --> 00:03:29,360 But later on this course you will learn more about the void and void functions here. 45 00:03:29,370 --> 00:03:31,260 So see you in the next lecture.