The way he makes every relatively “wrong” answer from his students seem somewhat right, but then reminds them that he’s looking for something else! Imagine how this little technique could have changed the lives of so many students who prolly gave up on a dream or career path because they were put down with some responses like “No”, “Not correct”.
I noticed it too the first time I started watching CS50 lectures! This is peak pedagogy! And you can feel that David love what he teaches, and how much he cares about his students.
The video covers the use of integers to calculate averages, the importance of using floats for accurate division, and the introduction to arrays in C programming. It also discusses the compiling process, debugging techniques, and the representation of strings as arrays of characters in computer memory. The importance of exit status codes, cryptography, and encryption concepts are also explained. 00:00 Exploring Reading Levels and Compiling Code 01:03CS50 week 2 begins with a story time activity to explore reading levels and writing code. 01:27Volunteers read different stories to determine the reading levels and discuss the characteristics of the text. 07:05The video transitions to discussing compiling code and the role of the make command in running a compiler. 08:49 Understanding Clang and Compiling Source Code 08:49Clang converts source code to machine code, but lacks user-friendliness. 09:16Clang defaults to naming output file 'a.out', which is not user-friendly. 14:59Compiling involves pre-processing, compiling, assembling, and linking. 17:41 Understanding the Compiling Process in C Programming 17:44The prototype for get_string is defined inside cs50.h. 19:30Preprocessing, compiling, assembling, and linking are the four steps in the compiling process. 24:22Compiling converts C code into assembly language, which is then converted to 0's and 1's in the assembling step. 26:27 Implications of Source Code to Machine Code and Debugging Techniques 26:31Compiling code implies potential for decompiling it, reversing 0's and 1's to source code. 27:11Reverse engineering machine code back to source code is challenging due to loss of variable and function names. 32:53Debugging techniques like using printf and helper functions are essential for identifying and fixing bugs in code. 35:17 Debugging with a Debugger: A Step-by-Step Guide 35:17Using a debugger to step through code line by line and understand its execution. 41:47Setting breakpoints to pause execution at specific lines of code and inspect variables. 42:54Stepping into functions to understand their internal execution and inspect variable values. 44:10 Debugging Techniques and Memory Representation in C 44:10Using debuggers like debug50 and VS Code's debugger can help visualize code execution step by step. 45:52Rubber duck debugging involves explaining code out loud to an inanimate object to identify logical errors. 51:53Memory in computers is represented as a canvas of bytes, and different data types occupy different amounts of memory. 53:03 Understanding Arrays and Memory in C Programming 53:03Using integers to calculate average of scores. 53:27The importance of using floats instead of integers for accurate division. 57:46Introduction to arrays and their syntax in C programming. 1:01:52 Improving Code Design and Working with Arrays 1:01:52Clearing the terminal and making scores again. 1:02:38Using a loop to improve code design and avoid repetition. 1:03:11Explaining the use of arrays and their indexing in C programming. 1:09:36Addressing the issue of calculating the length of an array in C. 1:10:43 Understanding Arrays and Strings in C 1:10:43Average function iterates over an array, adds up numbers, and divides by total number of numbers. 1:11:10Declaring a variable called scores of size n and iterating through the array. 1:18:35Exploring the concept of strings as arrays of characters in C. 1:19:34 Understanding Strings and Memory Representation 1:19:37Strings in C are represented as arrays of characters, and the computer uses a special sentinel value to indicate the end of a string. 1:21:07The sentinel value at the end of every string in a computer's memory is all 0 bits, indicating the end of the string. 1:23:48In C, strings are represented as arrays of characters, and the NUL value is used to terminate strings, ensuring proper memory representation. 1:28:23 Understanding Strings and Arrays in C 1:28:24A string is an array of characters. 1:29:54Arrays in C are zero-indexed and can be manipulated using loops. 1:33:30Demonstration of finding the length of a string and modularizing it into a function. 1:37:10 Exploring C Libraries and Header Files 1:37:10Understanding local variable scope in C 1:37:43Exploring the string.h library and strlen function 1:41:54Optimizing code efficiency by avoiding redundant function calls 1:44:58Using conditional statements to convert lowercase characters to uppercase 1:45:59 Using Command Line Arguments in C Programming 1:46:03Explaining how to print a character without a new line and force it to uppercase 1:46:21Leveraging ASCII chart to convert lowercase to uppercase without using CS50 1:50:06Introduction to using command line arguments in C programming 1:54:50 Understanding Command Line Arguments and Exit Statuses in C Programming 1:54:57Command line arguments allow for user input when running a program 2:00:08Exit statuses are special return values from a program, with 0 indicating success 1:56:31Using conditional statements, error checking can be implemented based on command line arguments 2:03:43 Understanding Exit Status Codes and Introduction to Cryptography 2:03:43Understanding exit status codes in C programming and the significance of return values. 2:05:58Introduction to cryptography, encryption, and the concept of plaintext and ciphertext. 2:07:15Explanation of simple ciphers like the Caesar cipher and the concept of keys in encryption.
I liked the detail about 72, 73, 33 used earlier without context and then having them as result changing variables from chars to integers and getting 'HI!' :)
This is fundamental knowledge that is typically taught in most high schools, at least in Europe. I often wonder why Americans would willingly accumulate a lifetime of debt to acquire such a basic understanding of computers.
I thought about that too, but it's probably the multiple lighting spotlights pointing straight at his face. If they are not LED models, they tend to get very hot, even if the air is on.
@@nightspicerit’s because it’s also a stage, and on stages, LED lights just can’t quite do the specific things needed for stage lighting, and not to the same level of ease as stage lighting. Like LEDs can definitely change color and stuff, but it requires a lot more extra tech and extra STUFF that stage lights just don’t need. Plus it’s a lot more expensive to get the right level of programmable LED lights that can do. It’s only been recently in the last few years that really good LED stage lighting has hit the scene. And Harvard might be super prestigious, but The Arts funding is always going to be on the lower end of the priority list and replacing the entire lighting system (and training/teaching how to use this new tech) just isn’t cost effective, especially since the industry as a whole hasn’t transitioned to LED lighting so students learning LED lighting techniques would not be as useful in the real world vs if they were learning what is actually in use.
I do really love the fact even if he is a teacher and a great programmer, he make mistake aswell. That make me more confident than even after years and years of programming you going to always make mistake even the basic one and you don't need to feel you are bad at programming.
If programmers and game devs didn’t naturally mess up, every now and then, bugreporting and QA wouldn’t exist. And to quote Bob Ross: „no mistakes, just happy little accidents“… or opportunities to learn from. Just don’t try to ignore and cover up crucial errors like xerox did when they were told their copiers occasionally turned „8“ into „0“… (story went through some tech magazines online a few years ago).
I’m currently taking the course, and it’s truly unique! The professor is incredible-the way he explains things with such clarity and energy is amazing. I’m still a bit sad that I can’t be there in person and have to do it online. I’d love to be that age again and study at a university like this!
The world of programming has changed drastically in the past 40 years. Regardless of your amount of experience you are inevitably going to constantly run into new things to learn, even at the most basic level.
00:03 Discussion about reading levels and story time 02:43 Reading levels can be determined using algorithms based on word and sentence complexity 06:40 Understanding the compilation process helps troubleshoot and solve problems more effectively. 08:54 Clang can be used simply for compilation, but requires command line arguments for customization. 13:16 Using libraries and introducing make for automating processes 15:27 Understanding the role of prototypes and preprocessor directives in C programming. 19:41 Code is compiled into assembly language which is then converted to machine code. 21:41 Compiling a program involves three files linked together in the final step. 26:00 Understanding the implications of compiling code to machine code. 27:50 Decompiling C code can be difficult to read without good variable names, function names, and documentation. 31:52 printf is a quick and dirty tool to see what's going on inside the computer. 33:49 Using printf for debugging can be helpful but overusing it can lead to trial and error approach 37:31 Debug50 helps with programmatic and logical errors in your code. 39:30 Variables in C can contain garbage values if not initialized 43:23 Using debug50 and VS Code's debugger for efficient debugging 45:20 Learning proper debugging techniques saves time and effort in the long run. 49:29 Data representation in terms of bytes 51:20 Computer memory is like a canvas of bytes for storing information. 55:11 Integers in memory are represented using 4 bytes and are stored back to back 57:11 Introduction to arrays and their benefits in managing multiple values in code. 1:01:24 Missed including the CS50 header file leading to implicit declaration of the function get_int. 1:03:10 Using arrays in a loop allows for dynamic referencing and more efficient code design. 1:07:05 Global variables are accessible to all functions in a file, but using constants is generally preferred. 1:09:13 In C, it is not easy to retrieve the length of an array, as in other languages. 1:13:21 Introduction to representing letters and words using arrays. 1:15:21 Characters and integers are interchangeable in C 1:19:22 Strings in C are essentially arrays of characters and can be accessed using array notation. 1:21:23 Strings in C use a zero value at the end to terminate the string. 1:25:22 Strings in C are implemented differently than in other languages 1:27:15 Using arrays to represent multiple variables in a more organized way. 1:31:19 In C, arrays should typically be of the same data type. 1:33:30 Creating a program to calculate the length of a string 1:37:24 The string library in C provides a popular function called strlen to find the length of a string. 1:39:27 Creating a program to iterate through a string and print each character. 1:43:34 Declaring variables of the same type is crucial for a trick to work 1:45:43 Forcing lowercase characters to uppercase using ASCII values. 1:49:45 Leveraging libraries to solve problems and taking off training wheels 1:51:49 C can handle command line arguments without get_string 1:55:58 Error checking with conditionals and iterating through command line arguments 1:58:07 ASCII art using traditional English letters and punctuation. 2:02:00 Programs can return values even if no command line arguments are used. 2:04:11 Understanding and utilizing program exit statuses. 2:08:03 Encryption using simple ciphers like Caesar cipher is not very secure in practice. 2:09:58 Understanding cryptographic ciphers and their operations
finally, after completing ps1, after watching and understanding sections and shorts i got to lection 2. i hope i understand this one. i was really struggling with ps1
1:39:02 For any one wondering where to find string.h, actually you don't need to download from elsewhere. It is a built in function. If you have any issue when compiling with Macbook pro arm64 error alert, use cc length.c -o length cs50.c to replace make length I have struggled a few minutes on this one. Hope it will be helpful to someone one day:)
1:42:34 Actually, in C, the condition of a loop is evaluated before each iteration. So, if we assign a function to a variable and use that variable as the condition inside the loop, the function will be called each time the loop condition is evaluated, not just once
I think it depends on the compiler you're using such as GCC, Clang, etc. Some compilers are "optimized" and smart enough to figure out that you only need to call the function once. And, from what I understand, certain functions are automatically optimized or recognized by the compiler when inside a loop such as the strlen function, for example. I guess, though, you would have to compile the C code and look at the Assembly code to see if the function call has actually been optimized or not?
The way it still ended with a bang!! I love education can still be interesting for people who don’t wanna just get good grades. If all of Harvard is this good then it’s really worth it❤
29:30 bonus story I read about Admiral Hopper, not sure how true but i keep it as head cannon. When she worked at the pentagon, since DOD didn't really know quite what to do with her department, or the value of her work, her office's supply requisition orders would get kicked to the back of the bottom of the list so it was difficult for her to get office supplies like pens, papers, paperclips. So she would after hours raid other peoples offices for supplies. Her friends at the pentagon then got her a little jolly roger flag for her desk. Thus was born the legend of Pirate Admiral Grace Hoper
00:00 🎙 Introduction and Story Time Introduction to week 2, featuring a story time activity with student volunteers, Students read various texts of increasing difficulty to determine reading levels. 05:16 🔐 Cryptography and Real-world Applications Introduction to cryptography and its importance in securely transmitting information, Explanation of how learning to scramble and encrypt data applies to practical scenarios. 06:12 🔧 Compiling Code and Understanding Make Introduction to the compiling process and the role of make in automating it, Explanation of how make simplifies using a compiler by running complex commands for the user. 10:28 📝 Command Line Arguments and Using Libraries Discussion on command line arguments and their role in configuring compiler behavior, Demonstration of how to compile code with additional libraries like the CS50 Library. 14:17 🛠 Four Steps of Compilation Detailed breakdown of the compilation process into four steps: preprocessing, compiling, assembling, and linking, Explanation of how preprocessing includes directives like hash include and their role in preparing code for compilation. 20:24 🖥 Overview of Compiling Steps Explanation of converting C code to machine code, Discussing abstraction levels, assembly language, and the role of compilers, Assembling and linking processes and their purpose in code compilation. 22:19 📂 Compiling Multiple Files Detailing the involvement of multiple files in compiling a simple program, Explanation of file dependencies: hello.c, cs50.c, and stdio.c, The importance of linking compiled files into one executable. 24:09 🔄 Detailed Breakdown of Compiling Clarifying the steps of compiling for better understanding, Differences between preprocessing, compiling, assembling, and linking, The role of the make command and how it simplifies the compilation process. 26:02 ⚙ Types of Compilers and Practical Implications Discussing various compilers like GCC and Clang, User-friendliness and error messages of different compilers, Potential to decompile and reverse engineer machine code, and its challenges. 28:20 🐞 Debugging Introduction The importance of debugging in programming, History of the term "bug" in computing, Common debugging techniques, starting with simple printf statements. 31:06 🛠 Using Printf for Debugging Example of identifying and fixing a bug using printf, The limitations of printf for complex debugging, Transitioning from printf to more sophisticated debugging tools. 34:22 🐛 Debugging with Helper Functions Structuring code with helper functions to isolate bugs, Adding prototypes and ensuring proper inclusion of header files, Common mistakes and how to systematically fix them. 37:11 🧩 Introduction to Debugging Tools Using debug50 to run the debugger in VS Code, Setting breakpoints to pause code execution and inspect behavior, Navigating the debugging interface andinterpreting its output. 40:01 🗑 Understanding Garbage Values Variables in C can contain garbage values before initialization, Explanation of stepping through code using the debugger, Importance of initializing variables to avoid nonsensical values. 42:22 🔄 Debugger Usage and Techniques Demonstration of stepping into and stepping over functions, Use of the debugger to watch variables change during code execution, Debugger tools as an efficient alternative to using printf for debugging. 45:45 🦆 Rubber Duck Debugging Introduction to rubber duck debugging, Explanation of how verbalizing code to an inanimate object can reveal logical errors, Mention of the CS50 Duck as a resource for debugging assistance. 47:37 🛠 Introduction to Lower-Level C Features Transition to discussing lower-level features of C, Importance of data types and memory allocation in programming, Explanation of integer sizes and the need for larger data types in some applications. 50:26 🖥 Memory and Data Representation Visualization of computer memory as a canvas of bytes, How different data types occupy memory space, Importance of understanding memory addresses and data storage. 52:22 📊 Calculating Averages and Integer Division Example of a program calculating the average of three scores, Issues with integer division and how to avoid losing precision, Demonstration of casting integers to floats for accurate calculations. 55:15 💻 Array Basics Introduction to arrays in C and their usage, Declaring an array and assigning values to its elements, Importance of zero-based indexing. 01:00:56 🛠 Dynamic Input with Arrays Making the program more interactive by using user input, Adding values to an array dynamically with get_int, Fixing errors related to missing headers. 01:02:20 🔄 Using Loops with Arrays Improving code by using loops to handle array elements, Avoiding repetitive code and reducing manual errors, Discussion of zero-indexing and average calculation. 01:05:33 🔧 Enhancing Array Handling Introducing constants to avoidmagic numbers, Use of global constants for array size, Benefits of declaring constants and scope considerations. 01:08:49 📏 Calculating Array Length Limitations of C in determining array length, Demonstration of a function to compute averages using arrays, Importance of keeping track of array size manually. 01:13:19 🔢 Characters and Numbers Representing characters and integers interchangeably in arrays, Printing characters and their integer equivalents, Memory representation of characters in arrays. 01:17:13 🔤 Strings as Arrays Introduction to strings as 01:19:04 🧵 Understanding Strings as Arrays Explanation of strings as arrays of characters, Using square bracket notation to access string characters, Demonstration of manipulating strings as arrays. 01:21:00 🛑 Sentinel Value in Strings Sentinel value (null character) indicates the end of a string, Explanation of null character (all 0 bits), Printing string characters and the sentinel value in memory. 01:24:17 🔢 String Length and Null Character Importance of null character in determining string length, Printing ASCII values of string characters, Concept of n + 1 length for strings due to the null character. 01:26:12 🧩 Arrays of Strings Creating and printing arrays of strings, Arrays of characters as a conceptual bridge to arrays of strings, Example of printing each character of a string using nested arrays. 01:29:00 🏗 Memory Representation of Strings Visual representation of strings in memory, How strings are stored and accessed using array syntax, Understanding two-dimensional arrays as a logical extension. 01:33:18 📏 Calculating String Length Writing a function to calculate string length manually, Using while 01:38:33 📚 Using Libraries to Simplify Code Introduction to using built-in functions to simplify programming tasks, Example of using strlen from string.h instead of writing custom code to calculate string length, Explanation of how including a header file allows the compiler to recognize library functions. 01:39:29 🔍 Iterating Over Strings Creating a program to print each character of a string individually, Demonstration of using a for loop to iterate through a string, Explanation of how the strlen function can be used inside the loop. 01:41:22 🕵 Optimizing Loop Performance Identifying inefficiencies in calling strlen repeatedly within a loop, Explanation of how to store the string length in a variable to optimize performance, Demonstrating a more efficient loop structure to avoid redundant function calls. 01:43:45 🆙 Converting Strings to Uppercase Writing a program to convert lowercase letters in a string to uppercase, 01:58:43 🐄 ASCII Art and Command Line Arguments Demonstrating the use of command line arguments with ASCII art, Examples include using cowsay with different flags to produce various outputs like "moo" or "quack." 02:00:11 🔢 Exit Status in Programs Explanation of exit statuses in programs and their significance, Discussing how different exit codes (e.g., 0 for success, other numbers for errors) are used and can be diagnosed. 02:06:04 🔒 Introduction to Cryptography Basics of encryption and the purpose of cryptography, Concepts such as plaintext, ciphertext, and keys, Explanation of how encryption makes messages secure even if intercepted. 02:07:57 🗝 Caesar Cipher Introduction to the Caesar Cipher as a simple encryption method, Details on shifting letters by a certain key (e.g., shifting "HI" to "IJ" with key 1). 02:09:25 🔄 ROT13 and Other Shifts ROT13 as a common cipher on the internet, Discussion on the limitations of simple ciphers like ROT26. 02:10:50 🔓 Decrypting Messages Process of decrypting messages by reversing the encryption key, Example of decrypting a message encrypted with a key of 1.
19:17 preprocessing converts all of the hash-include lines to whatever the underline prototypes are withing the file, plus some other staffs. 24:20 preprocessing, compiling, assembling, and linking 1:20:45 String, sentinel value, and string length is n+1, \0 --> 1:24:47 the technical term is NUL, not NULL. 1:41:50 new syntax for FOR loop 1:51:33 int main(arguments) 1:51:45 Command-line arguments 2:04:37 if you see the very recent return value, type this command in CLI: echo $?
Earlier this year I had to use a Python face recognition library for a school project and I had to install CMake and Clang to make it work. Probably because under the hood the library is written in C to make it run faster. Up until then I had never heard about CMake and Clang before and had no idea why I needed both and was just glad it worked after troubleshooting for hours. As I am watching this I finally realized why they co-exist. I also wish I had seen the debugging part earlier.... even a few days ago as I was learning about a Python implementation of Dijkstra's algorithm and doing exercises related to it I would (obviously) run into logical errors in my code. I sat there for hours just looking at the code and painstakingly putting print statements to try to figure it out. I did also use the debugging tool to place break points and look at the contents of the lists, dictionaries and what not, but I had no idea you can just pause it line by line and watch your program execute step by step. I did manage to solve the problem eventually (ultimately it wasn't that complex) but using the debugger properly would have saved me literal hours.
47:01 at this point I realized how many things I have been doing without thinking that have a proper name to them and are something useful, truly a physics moment
this course pretty cool I just started coding about a 2 month ago I pretty much know most of this stuff so far but I wanted to go thru all the exercises for any extra practice and info I might missed
Are you doing all the problem sets from the esX website. I think they make this course 10x better as it makes sure you practically apply what you've been taught in the lecture
@@vinicraftmaster7597 did you read my comment? i said they don't give you the resources to practice. To practice before doing the difficult problem sets.
1:24:49 He said "NUL means, this is the 0 byte that terminates strings that indicates the end of the string", but it really has a 1 byte in the memory space that it just means 0. not 0 bytes.
44:12 I was coding in cs code for many months and was using Python, HTML, CSS, and js as my coding languages but this bugging feature got me. I didn't know before that such an amazing thing exists in VS code. Thanks, Professor!
Hey there ! Actually I kinda suck at operating debugging would you help in this matter? I don't know which applications or other software will operate debug50.
Yea I got a question actually. How was someone without any previous programming supposed to do last weeks credit problem without seeing this video first? Woulda saved me a lot of time if I had.
length of array: int numbers[] = {1, 2, 3, 4, 5}; int length = sizeof(numbers) / sizeof(numbers[0]); // Calculate length printf("The length of the array is: %d ", length);
You can calculate the length of an array on the stack: #define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) The speaker was probably mistaken with a heap array.
Only if you are using it in the same function, Let say you pass the array to a function only the pointer to the first element were send to the function actually and you lose the how much size of a array is
1:35:11 if you start counting with 0, why does it output that David = 5? isnt the last d at index position 4? and its not counting \0 so isnt the answer 4?
try using the rubber duck debugging method (see 45:55) and work though an example line by line! to save time you can create a shorter example, such as if the user inputs "Bob": n starts at 0. • 1st time through while loop: name[0] = 'B', so while loop condition is met, so we execute n++. Now n=1. • 2nd time: name[1] = 'o', n++ so n=2. • 3rd time: name[2] = 'b', n++ so n=3. • 4th time: name[3] = '\0', which causes the program to break out of the while loop. so n gets printed out as 3. hope that makes sense, let me know if not!
It's a prototype function, it's basically telling the program that this function exists and we will be using it so if you call it earlier in the code before what it does is defined the compiler won't spit errors out at you
@@ZeroZeppelin length was the amount of numbers. In this case it was the constant N, which was 3. If you were to implement this function into your own program, you could put whatever the size of your sample is.
if you skipped lectures go back and watch them, you should be understanding this easily if you watched them, especially lecture 1, also the shorts are really helpful, i recommend watching every single one of them ( the shorts I'm talking about are the ones under the lecture on the cs50 website, not youtube shorts)
also solve the problem sets, you must solve them to get the certificate (obviously) and they help you to make sure you understand everything in the lecture
I just got back to these because it's amazing the amount of things that can happen in just two months and I cannot, for the life of me remember how it was that I was able to do everything in the command line using only vim, node and virtual environments xD And I really do not feel like learning all over again as I remember it took quite the amount of time and I had to install Arch Linux, also lost all of my music files because this laptop is obscenely small and weak. Should have got myself something better when I had the chance
@1:21:06 what about spaces in strings... how come spaces do not trigger what the same value triggers at the end of every string? I guess I know that its technically not just zero, but is actually \"0", right? But on the screen, it showed a series of zeros ("00000000" or so). How do we differentiate between '0000 0000 0000 0000 0000 0000 0000 0000' meaning the integer zero, and '0000 0000 0000 0000 0000 0000 0000 0000' meaning " "?
length is a value that you pass to the function, when you call the function in line 22 "average(N, scores)", you declare length on the function, "int length" is N. argc holds the amount of arguments the user types. In this case, ./greet david, ./greet is 1, david is 2. argc==2, is just "Is argc equals to 2"
The way he makes every relatively “wrong” answer from his students seem somewhat right, but then reminds them that he’s looking for something else!
Imagine how this little technique could have changed the lives of so many students who prolly gave up on a dream or career path because they were put down with some responses like “No”, “Not correct”.
I noticed it too the first time I started watching CS50 lectures! This is peak pedagogy! And you can feel that David love what he teaches, and how much he cares about his students.
Nice observation. Professor David Malan is amazing!
This younger gen should learn to grow a thicker skin tbh.
@@user-yk1cw8im4hpeople have said something to that effect every generation for thousands of years 🙄
This is helping me a ton because i'm no longer surrounded by people telling me "that's not for black people"
The video covers the use of integers to calculate averages, the importance of using floats for accurate division, and the introduction to arrays in C programming. It also discusses the compiling process, debugging techniques, and the representation of strings as arrays of characters in computer memory. The importance of exit status codes, cryptography, and encryption concepts are also explained.
00:00
Exploring Reading Levels and Compiling Code
01:03CS50 week 2 begins with a story time activity to explore reading levels and writing code.
01:27Volunteers read different stories to determine the reading levels and discuss the characteristics of the text.
07:05The video transitions to discussing compiling code and the role of the make command in running a compiler.
08:49
Understanding Clang and Compiling Source Code
08:49Clang converts source code to machine code, but lacks user-friendliness.
09:16Clang defaults to naming output file 'a.out', which is not user-friendly.
14:59Compiling involves pre-processing, compiling, assembling, and linking.
17:41
Understanding the Compiling Process in C Programming
17:44The prototype for get_string is defined inside cs50.h.
19:30Preprocessing, compiling, assembling, and linking are the four steps in the compiling process.
24:22Compiling converts C code into assembly language, which is then converted to 0's and 1's in the assembling step.
26:27
Implications of Source Code to Machine Code and Debugging Techniques
26:31Compiling code implies potential for decompiling it, reversing 0's and 1's to source code.
27:11Reverse engineering machine code back to source code is challenging due to loss of variable and function names.
32:53Debugging techniques like using printf and helper functions are essential for identifying and fixing bugs in code.
35:17
Debugging with a Debugger: A Step-by-Step Guide
35:17Using a debugger to step through code line by line and understand its execution.
41:47Setting breakpoints to pause execution at specific lines of code and inspect variables.
42:54Stepping into functions to understand their internal execution and inspect variable values.
44:10
Debugging Techniques and Memory Representation in C
44:10Using debuggers like debug50 and VS Code's debugger can help visualize code execution step by step.
45:52Rubber duck debugging involves explaining code out loud to an inanimate object to identify logical errors.
51:53Memory in computers is represented as a canvas of bytes, and different data types occupy different amounts of memory.
53:03
Understanding Arrays and Memory in C Programming
53:03Using integers to calculate average of scores.
53:27The importance of using floats instead of integers for accurate division.
57:46Introduction to arrays and their syntax in C programming.
1:01:52
Improving Code Design and Working with Arrays
1:01:52Clearing the terminal and making scores again.
1:02:38Using a loop to improve code design and avoid repetition.
1:03:11Explaining the use of arrays and their indexing in C programming.
1:09:36Addressing the issue of calculating the length of an array in C.
1:10:43
Understanding Arrays and Strings in C
1:10:43Average function iterates over an array, adds up numbers, and divides by total number of numbers.
1:11:10Declaring a variable called scores of size n and iterating through the array.
1:18:35Exploring the concept of strings as arrays of characters in C.
1:19:34
Understanding Strings and Memory Representation
1:19:37Strings in C are represented as arrays of characters, and the computer uses a special sentinel value to indicate the end of a string.
1:21:07The sentinel value at the end of every string in a computer's memory is all 0 bits, indicating the end of the string.
1:23:48In C, strings are represented as arrays of characters, and the NUL value is used to terminate strings, ensuring proper memory representation.
1:28:23
Understanding Strings and Arrays in C
1:28:24A string is an array of characters.
1:29:54Arrays in C are zero-indexed and can be manipulated using loops.
1:33:30Demonstration of finding the length of a string and modularizing it into a function.
1:37:10
Exploring C Libraries and Header Files
1:37:10Understanding local variable scope in C
1:37:43Exploring the string.h library and strlen function
1:41:54Optimizing code efficiency by avoiding redundant function calls
1:44:58Using conditional statements to convert lowercase characters to uppercase
1:45:59
Using Command Line Arguments in C Programming
1:46:03Explaining how to print a character without a new line and force it to uppercase
1:46:21Leveraging ASCII chart to convert lowercase to uppercase without using CS50
1:50:06Introduction to using command line arguments in C programming
1:54:50
Understanding Command Line Arguments and Exit Statuses in C Programming
1:54:57Command line arguments allow for user input when running a program
2:00:08Exit statuses are special return values from a program, with 0 indicating success
1:56:31Using conditional statements, error checking can be implemented based on command line arguments
2:03:43
Understanding Exit Status Codes and Introduction to Cryptography
2:03:43Understanding exit status codes in C programming and the significance of return values.
2:05:58Introduction to cryptography, encryption, and the concept of plaintext and ciphertext.
2:07:15Explanation of simple ciphers like the Caesar cipher and the concept of keys in encryption.
Much wow! Thanks!
Great work there! Thank you!!
nice i will definitely use this while completing pset 2 :)
69th like, nice.
Also, thanks for existing. 👍
i have 5+ years of dev experience + 5 additional years in uni , but still this is good to see
Amazing hope to be on your status one day
really reassuring, thanks for the comment, makes me want to keep going
I liked the detail about 72, 73, 33 used earlier without context and then having them as result changing variables from chars to integers and getting 'HI!' :)
ya fr
This course is killing all paid courses so far) Excited to see what's next!
As someone said: "You pay for the piece of paper and not for knowledge, knowledge is always free"
This is fundamental knowledge that is typically taught in most high schools, at least in Europe. I often wonder why Americans would willingly accumulate a lifetime of debt to acquire such a basic understanding of computers.
lol an american computer science degree is not a "basic understanding of computers" did you think this was an advanced class? @@-es2bf
@@-es2bfunfortunately it’s much more difficult to get a job without a degree.
I think way of teaching is so important, it is really hard to understand fundamentals and CS50 is great @@-es2bf
The best university in the world still doesn't have air conditioning to cool David. I'm sweating watching it.
I thought about that too, but it's probably the multiple lighting spotlights pointing straight at his face. If they are not LED models, they tend to get very hot, even if the air is on.
@@ToniusPlays that's what I was thinking, I wonder why they wouldn't switch to LEDs since they'd be way more power efficient, especially at his power
Stages are always hot.
@@nightspicerit’s because it’s also a stage, and on stages, LED lights just can’t quite do the specific things needed for stage lighting, and not to the same level of ease as stage lighting.
Like LEDs can definitely change color and stuff, but it requires a lot more extra tech and extra STUFF that stage lights just don’t need. Plus it’s a lot more expensive to get the right level of programmable LED lights that can do.
It’s only been recently in the last few years that really good LED stage lighting has hit the scene. And Harvard might be super prestigious, but The Arts funding is always going to be on the lower end of the priority list and replacing the entire lighting system (and training/teaching how to use this new tech) just isn’t cost effective, especially since the industry as a whole hasn’t transitioned to LED lighting so students learning LED lighting techniques would not be as useful in the real world vs if they were learning what is actually in use.
@@ToniusPlays he is also running around on stage while seemingly having to project his voice quite a bit.
2:09:30 In case it isn't obvious, the nice thing about rot13 is that decryption is the same as encryption. You're adding 13 either way.
I do really love the fact even if he is a teacher and a great programmer, he make mistake aswell. That make me more confident than even after years and years of programming you going to always make mistake even the basic one and you don't need to feel you are bad at programming.
100 percent agree
No your just bad
@@underlegengaukler you're** bad
@@underlegengauklergot yo ass
If programmers and game devs didn’t naturally mess up, every now and then, bugreporting and QA wouldn’t exist.
And to quote Bob Ross: „no mistakes, just happy little accidents“… or opportunities to learn from.
Just don’t try to ignore and cover up crucial errors like xerox did when they were told their copiers occasionally turned „8“ into „0“… (story went through some tech magazines online a few years ago).
I’m currently taking the course, and it’s truly unique! The professor is incredible-the way he explains things with such clarity and energy is amazing. I’m still a bit sad that I can’t be there in person and have to do it online. I’d love to be that age again and study at a university like this!
Currently retired and with 40 yrs tech exp but have been enjoying this. Moving on to 3rd session
why are you going through cs50 if you have had 40 years of exp
The world of programming has changed drastically in the past 40 years. Regardless of your amount of experience you are inevitably going to constantly run into new things to learn, even at the most basic level.
00:03 Discussion about reading levels and story time
02:43 Reading levels can be determined using algorithms based on word and sentence complexity
06:40 Understanding the compilation process helps troubleshoot and solve problems more effectively.
08:54 Clang can be used simply for compilation, but requires command line arguments for customization.
13:16 Using libraries and introducing make for automating processes
15:27 Understanding the role of prototypes and preprocessor directives in C programming.
19:41 Code is compiled into assembly language which is then converted to machine code.
21:41 Compiling a program involves three files linked together in the final step.
26:00 Understanding the implications of compiling code to machine code.
27:50 Decompiling C code can be difficult to read without good variable names, function names, and documentation.
31:52 printf is a quick and dirty tool to see what's going on inside the computer.
33:49 Using printf for debugging can be helpful but overusing it can lead to trial and error approach
37:31 Debug50 helps with programmatic and logical errors in your code.
39:30 Variables in C can contain garbage values if not initialized
43:23 Using debug50 and VS Code's debugger for efficient debugging
45:20 Learning proper debugging techniques saves time and effort in the long run.
49:29 Data representation in terms of bytes
51:20 Computer memory is like a canvas of bytes for storing information.
55:11 Integers in memory are represented using 4 bytes and are stored back to back
57:11 Introduction to arrays and their benefits in managing multiple values in code.
1:01:24 Missed including the CS50 header file leading to implicit declaration of the function get_int.
1:03:10 Using arrays in a loop allows for dynamic referencing and more efficient code design.
1:07:05 Global variables are accessible to all functions in a file, but using constants is generally preferred.
1:09:13 In C, it is not easy to retrieve the length of an array, as in other languages.
1:13:21 Introduction to representing letters and words using arrays.
1:15:21 Characters and integers are interchangeable in C
1:19:22 Strings in C are essentially arrays of characters and can be accessed using array notation.
1:21:23 Strings in C use a zero value at the end to terminate the string.
1:25:22 Strings in C are implemented differently than in other languages
1:27:15 Using arrays to represent multiple variables in a more organized way.
1:31:19 In C, arrays should typically be of the same data type.
1:33:30 Creating a program to calculate the length of a string
1:37:24 The string library in C provides a popular function called strlen to find the length of a string.
1:39:27 Creating a program to iterate through a string and print each character.
1:43:34 Declaring variables of the same type is crucial for a trick to work
1:45:43 Forcing lowercase characters to uppercase using ASCII values.
1:49:45 Leveraging libraries to solve problems and taking off training wheels
1:51:49 C can handle command line arguments without get_string
1:55:58 Error checking with conditionals and iterating through command line arguments
1:58:07 ASCII art using traditional English letters and punctuation.
2:02:00 Programs can return values even if no command line arguments are used.
2:04:11 Understanding and utilizing program exit statuses.
2:08:03 Encryption using simple ciphers like Caesar cipher is not very secure in practice.
2:09:58 Understanding cryptographic ciphers and their operations
Thanks for the notes my hero
@@XueDino my pleasure dude, imma do it in all the lectures 🤝
You're a beast 🚬🗿
This is my intro to coding, and I couldn't be happier (:
Yeah, I agree with that, Malan makes it damn easy to understand.
finally, after completing ps1, after watching and understanding sections and shorts i got to lection 2. i hope i understand this one. i was really struggling with ps1
Professor Malan Debugged "Debugging" in a most useful manner ever
Thanks You 😊
This course is so enjoyable! Thank you, David and Harvard University. Incredible content.
00:00:00 - Introduction
00:01:01 - Story Time
00:06:03 - Compiling
00:28:40 - Debugging
00:47:27 - Memory
00:52:37 - scores.c
00:57:39 - Arrays
01:13:59 - Strings
01:33:12 - String Length
01:44:33 - uppercase.c
01:50:05 - Command-line Arguments
01:57:58 - Cowsay
01:59:44 - Exit Status
02:05:48 - Cryptography
Although I've been into programming for about 5 years now, I'm learning a lot of new things. David Malan is the best.
I love how the amount of views consistently go down each video lmao
😂😂 why
@@huzeyfa8269 not everyone has the will to persis to learning sth that basic but crucial!
he is an amazing teacher, his passion pumps me to push through all the difficulties of this course!
1:39:02 For any one wondering where to find string.h, actually you don't need to download from elsewhere. It is a built in function.
If you have any issue when compiling with Macbook pro arm64 error alert, use
cc length.c -o length cs50.c
to replace make length
I have struggled a few minutes on this one. Hope it will be helpful to someone one day:)
1:42:34 Actually, in C, the condition of a loop is evaluated before each iteration. So, if we assign a function to a variable and use that variable as the condition inside the loop, the function will be called each time the loop condition is evaluated, not just once
Ps: I don't want to be rude; I just thought it might be helpful to clarify.
I think it depends on the compiler you're using such as GCC, Clang, etc. Some compilers are "optimized" and smart enough to figure out that you only need to call the function once.
And, from what I understand, certain functions are automatically optimized or recognized by the compiler when inside a loop such as the strlen function, for example.
I guess, though, you would have to compile the C code and look at the Assembly code to see if the function call has actually been optimized or not?
oh my goodness,this is the best course i ever taken!and the outro is so expressive!really thanks,david!
The way it still ended with a bang!! I love education can still be interesting for people who don’t wanna just get good grades. If all of Harvard is this good then it’s really worth it❤
29:30 bonus story I read about Admiral Hopper, not sure how true but i keep it as head cannon. When she worked at the pentagon, since DOD didn't really know quite what to do with her department, or the value of her work, her office's supply requisition orders would get kicked to the back of the bottom of the list so it was difficult for her to get office supplies like pens, papers, paperclips. So she would after hours raid other peoples offices for supplies. Her friends at the pentagon then got her a little jolly roger flag for her desk. Thus was born the legend of Pirate Admiral Grace Hoper
pure gold. of to the next one. after pset 2
00:00 🎙 Introduction and Story Time
Introduction to week 2, featuring a story time activity with student volunteers,
Students read various texts of increasing difficulty to determine reading levels.
05:16 🔐 Cryptography and Real-world Applications
Introduction to cryptography and its importance in securely transmitting information,
Explanation of how learning to scramble and encrypt data applies to practical scenarios.
06:12 🔧 Compiling Code and Understanding Make
Introduction to the compiling process and the role of make in automating it,
Explanation of how make simplifies using a compiler by running complex commands for the user.
10:28 📝 Command Line Arguments and Using Libraries
Discussion on command line arguments and their role in configuring compiler behavior,
Demonstration of how to compile code with additional libraries like the CS50 Library.
14:17 🛠 Four Steps of Compilation
Detailed breakdown of the compilation process into four steps: preprocessing, compiling, assembling, and linking,
Explanation of how preprocessing includes directives like hash include and their role in preparing code for compilation.
20:24 🖥 Overview of Compiling Steps
Explanation of converting C code to machine code,
Discussing abstraction levels, assembly language, and the role of compilers,
Assembling and linking processes and their purpose in code compilation.
22:19 📂 Compiling Multiple Files
Detailing the involvement of multiple files in compiling a simple program,
Explanation of file dependencies: hello.c, cs50.c, and stdio.c,
The importance of linking compiled files into one executable.
24:09 🔄 Detailed Breakdown of Compiling
Clarifying the steps of compiling for better understanding,
Differences between preprocessing, compiling, assembling, and linking,
The role of the make command and how it simplifies the compilation process.
26:02 ⚙ Types of Compilers and Practical Implications
Discussing various compilers like GCC and Clang,
User-friendliness and error messages of different compilers,
Potential to decompile and reverse engineer machine code, and its challenges.
28:20 🐞 Debugging Introduction
The importance of debugging in programming,
History of the term "bug" in computing,
Common debugging techniques, starting with simple printf statements.
31:06 🛠 Using Printf for Debugging
Example of identifying and fixing a bug using printf,
The limitations of printf for complex debugging,
Transitioning from printf to more sophisticated debugging tools.
34:22 🐛 Debugging with Helper Functions
Structuring code with helper functions to isolate bugs,
Adding prototypes and ensuring proper inclusion of header files,
Common mistakes and how to systematically fix them.
37:11 🧩 Introduction to Debugging Tools
Using debug50 to run the debugger in VS Code,
Setting breakpoints to pause code execution and inspect behavior,
Navigating the debugging interface andinterpreting its output.
40:01 🗑 Understanding Garbage Values
Variables in C can contain garbage values before initialization,
Explanation of stepping through code using the debugger,
Importance of initializing variables to avoid nonsensical values.
42:22 🔄 Debugger Usage and Techniques
Demonstration of stepping into and stepping over functions,
Use of the debugger to watch variables change during code execution,
Debugger tools as an efficient alternative to using printf for debugging.
45:45 🦆 Rubber Duck Debugging
Introduction to rubber duck debugging,
Explanation of how verbalizing code to an inanimate object can reveal logical errors,
Mention of the CS50 Duck as a resource for debugging assistance.
47:37 🛠 Introduction to Lower-Level C Features
Transition to discussing lower-level features of C,
Importance of data types and memory allocation in programming,
Explanation of integer sizes and the need for larger data types in some applications.
50:26 🖥 Memory and Data Representation
Visualization of computer memory as a canvas of bytes,
How different data types occupy memory space,
Importance of understanding memory addresses and data storage.
52:22 📊 Calculating Averages and Integer Division
Example of a program calculating the average of three scores,
Issues with integer division and how to avoid losing precision,
Demonstration of casting integers to floats for accurate calculations.
55:15 💻 Array Basics
Introduction to arrays in C and their usage,
Declaring an array and assigning values to its elements,
Importance of zero-based indexing.
01:00:56 🛠 Dynamic Input with Arrays
Making the program more interactive by using user input,
Adding values to an array dynamically with get_int,
Fixing errors related to missing headers.
01:02:20 🔄 Using Loops with Arrays
Improving code by using loops to handle array elements,
Avoiding repetitive code and reducing manual errors,
Discussion of zero-indexing and average calculation.
01:05:33 🔧 Enhancing Array Handling
Introducing constants to avoidmagic numbers,
Use of global constants for array size,
Benefits of declaring constants and scope considerations.
01:08:49 📏 Calculating Array Length
Limitations of C in determining array length,
Demonstration of a function to compute averages using arrays,
Importance of keeping track of array size manually.
01:13:19 🔢 Characters and Numbers
Representing characters and integers interchangeably in arrays,
Printing characters and their integer equivalents,
Memory representation of characters in arrays.
01:17:13 🔤 Strings as Arrays
Introduction to strings as
01:19:04 🧵 Understanding Strings as Arrays
Explanation of strings as arrays of characters,
Using square bracket notation to access string characters,
Demonstration of manipulating strings as arrays.
01:21:00 🛑 Sentinel Value in Strings
Sentinel value (null character) indicates the end of a string,
Explanation of null character (all 0 bits),
Printing string characters and the sentinel value in memory.
01:24:17 🔢 String Length and Null Character
Importance of null character in determining string length,
Printing ASCII values of string characters,
Concept of n + 1 length for strings due to the null character.
01:26:12 🧩 Arrays of Strings
Creating and printing arrays of strings,
Arrays of characters as a conceptual bridge to arrays of strings,
Example of printing each character of a string using nested arrays.
01:29:00 🏗 Memory Representation of Strings
Visual representation of strings in memory,
How strings are stored and accessed using array syntax,
Understanding two-dimensional arrays as a logical extension.
01:33:18 📏 Calculating String Length
Writing a function to calculate string length manually,
Using while
01:38:33 📚 Using Libraries to Simplify Code
Introduction to using built-in functions to simplify programming tasks,
Example of using strlen from string.h instead of writing custom code to calculate string length,
Explanation of how including a header file allows the compiler to recognize library functions.
01:39:29 🔍 Iterating Over Strings
Creating a program to print each character of a string individually,
Demonstration of using a for loop to iterate through a string,
Explanation of how the strlen function can be used inside the loop.
01:41:22 🕵 Optimizing Loop Performance
Identifying inefficiencies in calling strlen repeatedly within a loop,
Explanation of how to store the string length in a variable to optimize performance,
Demonstrating a more efficient loop structure to avoid redundant function calls.
01:43:45 🆙 Converting Strings to Uppercase
Writing a program to convert lowercase letters in a string to uppercase,
01:58:43 🐄 ASCII Art and Command Line Arguments
Demonstrating the use of command line arguments with ASCII art,
Examples include using cowsay with different flags to produce various outputs like "moo" or "quack."
02:00:11 🔢 Exit Status in Programs
Explanation of exit statuses in programs and their significance,
Discussing how different exit codes (e.g., 0 for success, other numbers for errors) are used and can be diagnosed.
02:06:04 🔒 Introduction to Cryptography
Basics of encryption and the purpose of cryptography,
Concepts such as plaintext, ciphertext, and keys,
Explanation of how encryption makes messages secure even if intercepted.
02:07:57 🗝 Caesar Cipher
Introduction to the Caesar Cipher as a simple encryption method,
Details on shifting letters by a certain key (e.g., shifting "HI" to "IJ" with key 1).
02:09:25 🔄 ROT13 and Other Shifts
ROT13 as a common cipher on the internet,
Discussion on the limitations of simple ciphers like ROT26.
02:10:50 🔓 Decrypting Messages
Process of decrypting messages by reversing the encryption key,
Example of decrypting a message encrypted with a key of 1.
Mr. Malan is a fantastic presenter
19:17 preprocessing converts all of the hash-include lines to whatever the underline prototypes are withing the file, plus some other staffs.
24:20 preprocessing, compiling, assembling, and linking
1:20:45 String, sentinel value, and string length is n+1, \0 --> 1:24:47 the technical term is NUL, not NULL.
1:41:50 new syntax for FOR loop
1:51:33 int main(arguments)
1:51:45 Command-line arguments
2:04:37 if you see the very recent return value, type this command in CLI: echo $?
Back in school, I got a lot of beatings from teachers whenever I got an answer wrong. I wish that every teacher was like him.
Earlier this year I had to use a Python face recognition library for a school project and I had to install CMake and Clang to make it work. Probably because under the hood the library is written in C to make it run faster. Up until then I had never heard about CMake and Clang before and had no idea why I needed both and was just glad it worked after troubleshooting for hours. As I am watching this I finally realized why they co-exist.
I also wish I had seen the debugging part earlier.... even a few days ago as I was learning about a Python implementation of Dijkstra's algorithm and doing exercises related to it I would (obviously) run into logical errors in my code. I sat there for hours just looking at the code and painstakingly putting print statements to try to figure it out. I did also use the debugging tool to place break points and look at the contents of the lists, dictionaries and what not, but I had no idea you can just pause it line by line and watch your program execute step by step. I did manage to solve the problem eventually (ultimately it wasn't that complex) but using the debugger properly would have saved me literal hours.
Just finished , learnt so much in this.
Mr. David is a great teacher.
47:01 at this point I realized how many things I have been doing without thinking that have a proper name to them and are something useful, truly a physics moment
this course pretty cool I just started coding about a 2 month ago I pretty much know most of this stuff so far but I wanted to go thru all the exercises for any extra practice and info I might missed
44:50 That's really helpful advice. 👏
What a pleasure to watch! Thank you :)
this is good i cant be bothered to learn c on my own but this is entertaining so im watching it
Wasting ur time if just watching lmao
The best explanation of array
Robert from Brasil 🎉 Another one whatched!
35:50 JAJAJAJAJAJAJ. I might look simple and stupid but this little details make the learning process better
this was a hilarious bit of the lecture
Absolutly amazing lecture. Starting was boring but end was very interesting .
1st lecture was pure fun , but lecture 2 was hard.
Are you doing all the problem sets from the esX website. I think they make this course 10x better as it makes sure you practically apply what you've been taught in the lecture
Practice, programming is hard but easy at the same time if you practice
@@vinicraftmaster7597 they dont exactly give you the resources to practice. the problem sets are not for beginners.
@@jp23x And how do you think you're going to learn? It's by trying
@@vinicraftmaster7597 did you read my comment? i said they don't give you the resources to practice. To practice before doing the difficult problem sets.
Whose here jumping classes forward and not waiting till next week to go through current lectures faster? :) Goodluck!
The cliffhanger something bad would happen kept me tied 😂
1:24:49 He said "NUL means, this is the 0 byte that terminates strings that indicates the end of the string", but it really has a 1 byte in the memory space that it just means 0. not 0 bytes.
1:14 strings
1:33:00 string length
1:42:00
Imagine going on stage for cookies and getting a book instead.
Yeah, I was sad for them lol
why would they think theyre getting cookies
@@samuelhernandez4135The volunteers from previous lectures got cookies lol
Pain💀😂
A college degree can be used to make money to buy many cookies.
44:12 I was coding in cs code for many months and was using Python, HTML, CSS, and js as my coding languages but this bugging feature got me. I didn't know before that such an amazing thing exists in VS code. Thanks, Professor!
wow, the course is soo enjoyable! loving it.
Bravo! Brilliant lecture!
wow this debug50 stuff sure would have been useful during the trenches of credit..
i was looking at those printed variables like a pilot at the dashboard man i was locked tf in
Hey there ! Actually I kinda suck at operating debugging would you help in this matter?
I don't know which applications or other software will operate debug50.
best lecture so far this was so fun
This is fantastic.
This is very usefull content.
Awesome stuff!
its been 10 day and i can say it was fun!
So are u still going?
It feels we will grow older with Mr. David Malan
Thank you, David
Yea I got a question actually. How was someone without any previous programming supposed to do last weeks credit problem without seeing this video first? Woulda saved me a lot of time if I had.
Day 2 : Completed!
Amazing 👉🏽✨✨✨
the quality of content is just next lvl .
length of array:
int numbers[] = {1, 2, 3, 4, 5};
int length = sizeof(numbers) / sizeof(numbers[0]); // Calculate length
printf("The length of the array is: %d
", length);
Incredible!
2:11:28 where is my rubber duck?😂
Thnx | respect | repeat
Let's go Grace Hopper! Hopper division at FIRST Championship was the best!
I have been using rubber duck debugging without knowing about it, I talk to myself what is program is doing and believe me it's really helpful XD.
thanks GS MALAN
You can calculate the length of an array on the stack:
#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0])))
The speaker was probably mistaken with a heap array.
Only if you are using it in the same function, Let say you pass the array to a function only the pointer to the first element were send to the function actually and you lose the how much size of a array is
@@darksider6113 Yes! If the parameter is a pointer (usually should be), then 'sizeof(pointer)' just alwas returns 4 or 8 Bytes.
We also want some snacks here!
just went outside no rubber duck was there false advertising
Lmaooo
Thanks ❤❤
lecture 2, gl to everyone
So good
1:35:11 if you start counting with 0, why does it output that David = 5? isnt the last d at index position 4? and its not counting \0 so isnt the answer 4?
try using the rubber duck debugging method (see 45:55) and work though an example line by line! to save time you can create a shorter example, such as if the user inputs "Bob":
n starts at 0.
• 1st time through while loop: name[0] = 'B', so while loop condition is met, so we execute n++. Now n=1.
• 2nd time: name[1] = 'o', n++ so n=2.
• 3rd time: name[2] = 'b', n++ so n=3.
• 4th time: name[3] = '\0', which causes the program to break out of the while loop. so n gets printed out as 3.
hope that makes sense, let me know if not!
@ninevolt tq I was having same doubt
Every time he says "see" i just say bun intended in my mind :D
On the example starting at 1:10:00, is “length” not supposed to be assigned a value?
It's a prototype function, it's basically telling the program that this function exists and we will be using it so if you call it earlier in the code before what it does is defined the compiler won't spit errors out at you
But whats the meaning of “length” in the function? Where is came from?
@@ZeroZeppelin length was the amount of numbers. In this case it was the constant N, which was 3. If you were to implement this function into your own program, you could put whatever the size of your sample is.
This is like junior high no lie
كورس فخم
Wish I knew debug50 when doing credit!
Thabk you
The intro reminds me of some TV series, like the Game of Thrones.
Respect
Yeahhhhhhh 🎉🎉🎉🎉🎉🎉
29:43 debugging
Personal Bookmark 48:00
C doesn’t have a string type by default, it is implemented in the cs50.h file right?
yes it was implemented in the cs50.h file,
So anyone know what lightbulbs had encrypted in them? I don't think I can see the binary from the video.
1:37:00
I dont get why its a bug help me. Also why do we need to return n? Im a beginner please help me. Thanks!
Bc name doesn't exist inside the function
if you skipped lectures go back and watch them, you should be understanding this easily if you watched them, especially lecture 1, also the shorts are really helpful, i recommend watching every single one of them ( the shorts I'm talking about are the ones under the lecture on the cs50 website, not youtube shorts)
also solve the problem sets, you must solve them to get the certificate (obviously) and they help you to make sure you understand everything in the lecture
@@Gha_210 Thank you
@@Albertmars32 Thank you
I just got back to these because it's amazing the amount of things that can happen in just two months and I cannot, for the life of me remember how it was that I was able to do everything in the command line using only vim, node and virtual environments xD And I really do not feel like learning all over again as I remember it took quite the amount of time and I had to install Arch Linux, also lost all of my music files because this laptop is obscenely small and weak. Should have got myself something better when I had the chance
35:56 that made me laugh so hard lol
@1:21:06 what about spaces in strings... how come spaces do not trigger what the same value triggers at the end of every string? I guess I know that its technically not just zero, but is actually \"0", right? But on the screen, it showed a series of zeros ("00000000" or so). How do we differentiate between '0000 0000 0000 0000 0000 0000 0000 0000' meaning the integer zero, and '0000 0000 0000 0000 0000 0000 0000 0000' meaning "
"?
David J Malan is perfect person
in my line 7 its saying the name is unidentified
Array of sunshine.
51:03
I literally counted it and it was 128
I think it is 128GB RAM
i just noticed i had a duck on my desk all along, literally.... just didnt think it was meaningful when i first saw the duck in the course`s cover
01:13:59
where is the value of int length declared? 1:13:20
argc == 2? didn't get. 1:56:12
length is a value that you pass to the function, when you call the function in line 22 "average(N, scores)", you declare length on the function, "int length" is N.
argc holds the amount of arguments the user types. In this case, ./greet david, ./greet is 1, david is 2. argc==2, is just "Is argc equals to 2"