1 00:00:00,000 --> 00:00:00,660 2 00:00:00,660 --> 00:00:03,890 >> SPEAKER: Recall that in C, all data types have a particular size. 3 00:00:03,890 --> 00:00:07,560 But that size may very well vary based on the computer on which you're using 4 00:00:07,560 --> 00:00:12,070 C. Now, we happen to be using C inside of the CS50 appliance, so inside of 5 00:00:12,070 --> 00:00:14,210 the appliance, how big is a char? 6 00:00:14,210 --> 00:00:15,270 How big is a double? 7 00:00:15,270 --> 00:00:16,430 How big is an int? 8 00:00:16,430 --> 00:00:17,790 How big is a float? 9 00:00:17,790 --> 00:00:20,530 >> Well, let's take a look with some code. 10 00:00:20,530 --> 00:00:26,760 Include standard io.h, int main void. 11 00:00:26,760 --> 00:00:29,100 And now let's begin to declare a few variables whose 12 00:00:29,100 --> 00:00:31,330 sizes we'll then print-- 13 00:00:31,330 --> 00:00:38,490 char c, double d, float f, and int i. 14 00:00:38,490 --> 00:00:41,180 Now, I'm not going to store any values in these variables, because I only 15 00:00:41,180 --> 00:00:43,060 care about their particular size. 16 00:00:43,060 --> 00:00:46,870 >> To see their size, I'll use print f, as well as a C operator called size 17 00:00:46,870 --> 00:00:49,600 of, which will answer exactly that question. 18 00:00:49,600 --> 00:00:50,900 Let's take a look. 19 00:00:50,900 --> 00:00:56,590 Print f char, followed by a colon, percent 1, backslash n. 20 00:00:56,590 --> 00:01:00,680 In other words, I want to print out char colon, followed by its size. 21 00:01:00,680 --> 00:01:05,540 >> So I'll include a comma followed by size of c. 22 00:01:05,540 --> 00:01:07,780 Let's now do this again for a double. 23 00:01:07,780 --> 00:01:16,090 Print f, double, percent i, backslash n, close quote, comma, size of d. 24 00:01:16,090 --> 00:01:19,885 Now notice, I'm going to continue using percent i, thereby signifying an 25 00:01:19,885 --> 00:01:23,440 int, because what isn't changing is the units in which I'm measuring the 26 00:01:23,440 --> 00:01:25,140 size of these variables. 27 00:01:25,140 --> 00:01:28,760 >> In fact, size of is going to return some number of bytes, maybe one, maybe 28 00:01:28,760 --> 00:01:29,990 two, maybe more. 29 00:01:29,990 --> 00:01:32,500 But in each case, it will indeed give me an int. 30 00:01:32,500 --> 00:01:35,640 And so that's the place holder I want to use, irrespective of the type, 31 00:01:35,640 --> 00:01:37,130 whose size I'm getting. 32 00:01:37,130 --> 00:01:39,290 Let's do two more print f's. 33 00:01:39,290 --> 00:01:45,950 >> Float, percent i, backslash n, size of f. 34 00:01:45,950 --> 00:01:53,250 Print f, int, percent i, backslash n, size of i. 35 00:01:53,250 --> 00:01:56,410 Let's now save, compile, and run this program. 36 00:01:56,410 --> 00:02:02,960 Make, size of, dot slash, size of, and we see that in the CS50 appliance, a 37 00:02:02,960 --> 00:02:08,500 char is one byte, a double is eight bytes, a float is 4 bytes, and an int 38 00:02:08,500 --> 00:02:09,750 is four bytes, as well. 39 00:02:09,750 --> 00:02:10,401