CS50x 2024 - Lecture 2 - Arrays

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.พ. 2025

ความคิดเห็น • 344

  • @kunlemaxwell
    @kunlemaxwell 8 หลายเดือนก่อน +432

    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”.

    • @PeterBee911
      @PeterBee911 8 หลายเดือนก่อน +40

      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.

    • @joangavelan
      @joangavelan 7 หลายเดือนก่อน +7

      Nice observation. Professor David Malan is amazing!

    • @user-yk1cw8im4h
      @user-yk1cw8im4h 7 หลายเดือนก่อน +10

      This younger gen should learn to grow a thicker skin tbh.

    • @BrainInAVat7
      @BrainInAVat7 7 หลายเดือนก่อน

      @@user-yk1cw8im4hpeople have said something to that effect every generation for thousands of years 🙄

    • @envygreen7051
      @envygreen7051 6 หลายเดือนก่อน +4

      This is helping me a ton because i'm no longer surrounded by people telling me "that's not for black people"

  • @botify9400
    @botify9400 ปีที่แล้ว +129

    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.

    • @PeterBee911
      @PeterBee911 8 หลายเดือนก่อน +4

      Much wow! Thanks!

    • @marajd2173
      @marajd2173 7 หลายเดือนก่อน +2

      Great work there! Thank you!!

    • @Dominion78
      @Dominion78 5 หลายเดือนก่อน +1

      nice i will definitely use this while completing pset 2 :)

    • @Choshmeesh
      @Choshmeesh 5 หลายเดือนก่อน +1

      69th like, nice.
      Also, thanks for existing. 👍

  • @mehdiyahiacherif2326
    @mehdiyahiacherif2326 ปีที่แล้ว +146

    i have 5+ years of dev experience + 5 additional years in uni , but still this is good to see

    • @apolmedrano3914
      @apolmedrano3914 ปีที่แล้ว +6

      Amazing hope to be on your status one day

    • @Adriel_rdj86
      @Adriel_rdj86 11 หลายเดือนก่อน +10

      really reassuring, thanks for the comment, makes me want to keep going

  • @zawepygler1223
    @zawepygler1223 10 หลายเดือนก่อน +91

    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!' :)

  • @OfficialCodeVoyage
    @OfficialCodeVoyage ปีที่แล้ว +151

    This course is killing all paid courses so far) Excited to see what's next!

    • @GCKteamKrispy
      @GCKteamKrispy ปีที่แล้ว +32

      As someone said: "You pay for the piece of paper and not for knowledge, knowledge is always free"

    • @-es2bf
      @-es2bf ปีที่แล้ว +18

      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.

    • @robloxpants
      @robloxpants ปีที่แล้ว

      lol an american computer science degree is not a "basic understanding of computers" did you think this was an advanced class? @@-es2bf

    • @therealist2000
      @therealist2000 ปีที่แล้ว +5

      @@-es2bfunfortunately it’s much more difficult to get a job without a degree.

    • @mukaddes_ihtiyar
      @mukaddes_ihtiyar ปีที่แล้ว

      I think way of teaching is so important, it is really hard to understand fundamentals and CS50 is great @@-es2bf

  • @grindinguy
    @grindinguy ปีที่แล้ว +496

    The best university in the world still doesn't have air conditioning to cool David. I'm sweating watching it.

    • @ToniusPlays
      @ToniusPlays ปีที่แล้ว +77

      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.

    • @nightspicer
      @nightspicer ปีที่แล้ว +14

      @@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

    • @yenthompson9471
      @yenthompson9471 11 หลายเดือนก่อน +12

      Stages are always hot.

    • @yenthompson9471
      @yenthompson9471 11 หลายเดือนก่อน +20

      @@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.

    • @fuckbitchesgehmoney
      @fuckbitchesgehmoney 10 หลายเดือนก่อน

      @@ToniusPlays he is also running around on stage while seemingly having to project his voice quite a bit.

  • @martinepstein9826
    @martinepstein9826 10 หลายเดือนก่อน +27

    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.

  • @fenneck9676
    @fenneck9676 ปีที่แล้ว +98

    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.

    • @d.k.1545
      @d.k.1545 ปีที่แล้ว +5

      100 percent agree

    • @underlegengaukler
      @underlegengaukler ปีที่แล้ว +2

      No your just bad

    • @d.k.1545
      @d.k.1545 ปีที่แล้ว +34

      @@underlegengaukler you're** bad

    • @apolmedrano3914
      @apolmedrano3914 ปีที่แล้ว

      ​@@underlegengauklergot yo ass

    • @ClashClash89
      @ClashClash89 7 หลายเดือนก่อน +5

      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).

  • @dudebro777
    @dudebro777 3 หลายเดือนก่อน +2

    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!

  • @wallacefalanGmail
    @wallacefalanGmail 11 หลายเดือนก่อน +23

    Currently retired and with 40 yrs tech exp but have been enjoying this. Moving on to 3rd session

    • @kelvinmontage9001
      @kelvinmontage9001 2 หลายเดือนก่อน +1

      why are you going through cs50 if you have had 40 years of exp

    • @Bruceja
      @Bruceja 2 หลายเดือนก่อน +1

      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.

  • @vedanshsrivastava9111
    @vedanshsrivastava9111 7 หลายเดือนก่อน +24

    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

    • @XueDino
      @XueDino 6 หลายเดือนก่อน +1

      Thanks for the notes my hero

    • @vedanshsrivastava9111
      @vedanshsrivastava9111 6 หลายเดือนก่อน +2

      @@XueDino my pleasure dude, imma do it in all the lectures 🤝

    • @JossephTrump
      @JossephTrump หลายเดือนก่อน

      You're a beast 🚬🗿

  • @veronicasmemories
    @veronicasmemories 10 หลายเดือนก่อน +12

    This is my intro to coding, and I couldn't be happier (:

    • @prasannahd
      @prasannahd 7 หลายเดือนก่อน +1

      Yeah, I agree with that, Malan makes it damn easy to understand.

  • @luizashabetnick8059
    @luizashabetnick8059 5 หลายเดือนก่อน +4

    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

  • @Ahmad-yi6d
    @Ahmad-yi6d 5 หลายเดือนก่อน +3

    Professor Malan Debugged "Debugging" in a most useful manner ever
    Thanks You 😊

  • @jetSonic
    @jetSonic 8 หลายเดือนก่อน +17

    This course is so enjoyable! Thank you, David and Harvard University. Incredible content.

  • @Yami-e1y
    @Yami-e1y 7 หลายเดือนก่อน +5

    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

  • @tahmidrzishan
    @tahmidrzishan 4 หลายเดือนก่อน +3

    Although I've been into programming for about 5 years now, I'm learning a lot of new things. David Malan is the best.

  • @ajm8169
    @ajm8169 5 หลายเดือนก่อน +26

    I love how the amount of views consistently go down each video lmao

    • @huzeyfa8269
      @huzeyfa8269 26 วันที่ผ่านมา

      😂😂 why

    • @lamardavis1465
      @lamardavis1465 24 วันที่ผ่านมา

      @@huzeyfa8269 not everyone has the will to persis to learning sth that basic but crucial!

  • @eko12
    @eko12 4 หลายเดือนก่อน

    he is an amazing teacher, his passion pumps me to push through all the difficulties of this course!

  • @fafner333
    @fafner333 4 หลายเดือนก่อน +2

    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:)

  • @ProGamer2001
    @ProGamer2001 9 หลายเดือนก่อน +6

    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

    • @ProGamer2001
      @ProGamer2001 9 หลายเดือนก่อน

      Ps: I don't want to be rude; I just thought it might be helpful to clarify.

    • @alainrouleau
      @alainrouleau 9 หลายเดือนก่อน +1

      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?

  • @mezumchran4162
    @mezumchran4162 ปีที่แล้ว +3

    oh my goodness,this is the best course i ever taken!and the outro is so expressive!really thanks,david!

  • @waqarishaqui348
    @waqarishaqui348 3 หลายเดือนก่อน

    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❤

  • @binaryburnout3d
    @binaryburnout3d 6 หลายเดือนก่อน +3

    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

  • @BlaseAnDerHand
    @BlaseAnDerHand 10 หลายเดือนก่อน +4

    pure gold. of to the next one. after pset 2

  • @quickclipz56
    @quickclipz56 หลายเดือนก่อน +1

    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.

  • @drawnsequence
    @drawnsequence 9 หลายเดือนก่อน +4

    Mr. Malan is a fantastic presenter

  • @BestHomeOman
    @BestHomeOman 3 หลายเดือนก่อน

    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 $?

  • @aymanewild2983
    @aymanewild2983 4 หลายเดือนก่อน +2

    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.

  • @Bruceja
    @Bruceja 2 หลายเดือนก่อน

    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.

  • @riyajath_hmd
    @riyajath_hmd ปีที่แล้ว +2

    Just finished , learnt so much in this.

  • @tayahrai
    @tayahrai 4 หลายเดือนก่อน

    Mr. David is a great teacher.

  • @licnex
    @licnex 4 หลายเดือนก่อน

    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

  • @big123lak
    @big123lak ปีที่แล้ว +6

    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

  • @ImHansana123
    @ImHansana123 5 หลายเดือนก่อน +2

    44:50 That's really helpful advice. 👏

  • @Nillipilli
    @Nillipilli 8 หลายเดือนก่อน

    What a pleasure to watch! Thank you :)

  • @carnap355
    @carnap355 ปีที่แล้ว +2

    this is good i cant be bothered to learn c on my own but this is entertaining so im watching it

    • @davidomar742
      @davidomar742 10 หลายเดือนก่อน +5

      Wasting ur time if just watching lmao

  • @lebronisthegoatla
    @lebronisthegoatla 7 วันที่ผ่านมา

    The best explanation of array

  • @robertdiasmello
    @robertdiasmello 3 หลายเดือนก่อน +1

    Robert from Brasil 🎉 Another one whatched!

  • @diegomaterano6352
    @diegomaterano6352 ปีที่แล้ว +3

    35:50 JAJAJAJAJAJAJ. I might look simple and stupid but this little details make the learning process better

    • @nightspicer
      @nightspicer ปีที่แล้ว

      this was a hilarious bit of the lecture

  • @VivekKumar-zb2sx
    @VivekKumar-zb2sx 3 หลายเดือนก่อน

    Absolutly amazing lecture. Starting was boring but end was very interesting .

  • @sahilvermaH
    @sahilvermaH ปีที่แล้ว +13

    1st lecture was pure fun , but lecture 2 was hard.

    • @sabih__
      @sabih__ 11 หลายเดือนก่อน +4

      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
      @vinicraftmaster7597 8 หลายเดือนก่อน

      Practice, programming is hard but easy at the same time if you practice

    • @jp23x
      @jp23x 6 หลายเดือนก่อน +2

      @@vinicraftmaster7597 they dont exactly give you the resources to practice. the problem sets are not for beginners.

    • @vinicraftmaster7597
      @vinicraftmaster7597 6 หลายเดือนก่อน +1

      @@jp23x And how do you think you're going to learn? It's by trying

    • @jp23x
      @jp23x 6 หลายเดือนก่อน +1

      @@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.

  • @ThatLionessGirl
    @ThatLionessGirl 5 หลายเดือนก่อน +1

    Whose here jumping classes forward and not waiting till next week to go through current lectures faster? :) Goodluck!

  • @LoneWolf-oo6jw
    @LoneWolf-oo6jw 8 หลายเดือนก่อน +3

    The cliffhanger something bad would happen kept me tied 😂

  • @이윤서-i5w
    @이윤서-i5w 4 หลายเดือนก่อน +1

    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.

  • @phol5082
    @phol5082 4 หลายเดือนก่อน

    1:14 strings
    1:33:00 string length
    1:42:00

  • @SwampyColorado420
    @SwampyColorado420 9 หลายเดือนก่อน +29

    Imagine going on stage for cookies and getting a book instead.

    • @layssaribeiro-oj9fd
      @layssaribeiro-oj9fd 9 หลายเดือนก่อน +4

      Yeah, I was sad for them lol

    • @samuelhernandez4135
      @samuelhernandez4135 7 หลายเดือนก่อน

      why would they think theyre getting cookies

    • @tigana
      @tigana 5 หลายเดือนก่อน

      @@samuelhernandez4135The volunteers from previous lectures got cookies lol

    • @tigana
      @tigana 5 หลายเดือนก่อน

      Pain💀😂

    • @teagancombest6049
      @teagancombest6049 หลายเดือนก่อน

      A college degree can be used to make money to buy many cookies.

  • @ayeshafarrukhsheikh
    @ayeshafarrukhsheikh 6 หลายเดือนก่อน +1

    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!

  • @aankushchauhan
    @aankushchauhan 7 หลายเดือนก่อน

    wow, the course is soo enjoyable! loving it.

  • @RobertMooney-ut7cc
    @RobertMooney-ut7cc 5 หลายเดือนก่อน

    Bravo! Brilliant lecture!

  • @grqfes
    @grqfes 8 หลายเดือนก่อน +5

    wow this debug50 stuff sure would have been useful during the trenches of credit..

    • @grqfes
      @grqfes 8 หลายเดือนก่อน

      i was looking at those printed variables like a pilot at the dashboard man i was locked tf in

    • @SaadKhan-jw2ck
      @SaadKhan-jw2ck 3 หลายเดือนก่อน

      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.

  • @jrupp2823
    @jrupp2823 9 หลายเดือนก่อน +2

    best lecture so far this was so fun

  • @MatVenuZ
    @MatVenuZ ปีที่แล้ว +1

    This is fantastic.

  • @bobbyG883
    @bobbyG883 ปีที่แล้ว +2

    This is very usefull content.

  • @antonioskokiantonis7051
    @antonioskokiantonis7051 ปีที่แล้ว +1

    Awesome stuff!

  • @Altercation.global
    @Altercation.global 8 หลายเดือนก่อน

    its been 10 day and i can say it was fun!

  • @hasibahmad297
    @hasibahmad297 11 หลายเดือนก่อน +1

    It feels we will grow older with Mr. David Malan

  • @ToniusPlays
    @ToniusPlays ปีที่แล้ว

    Thank you, David

  • @simspawn
    @simspawn หลายเดือนก่อน +1

    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.

  • @sourabhhsethii7292
    @sourabhhsethii7292 7 หลายเดือนก่อน

    Day 2 : Completed!

  • @WizeChoice
    @WizeChoice 10 หลายเดือนก่อน

    Amazing 👉🏽✨✨✨

  • @Aman-fz1ew
    @Aman-fz1ew ปีที่แล้ว

    the quality of content is just next lvl .

  • @128mtd128
    @128mtd128 3 หลายเดือนก่อน

    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);

  • @darshanjain8874
    @darshanjain8874 7 หลายเดือนก่อน

    Incredible!

  • @trushnasarvaiya4414
    @trushnasarvaiya4414 หลายเดือนก่อน +2

    2:11:28 where is my rubber duck?😂

  • @iTravel0816
    @iTravel0816 2 หลายเดือนก่อน

    Thnx | respect | repeat

  • @lawfpv
    @lawfpv 4 หลายเดือนก่อน

    Let's go Grace Hopper! Hopper division at FIRST Championship was the best!

  • @nitin_kashyap1926
    @nitin_kashyap1926 ปีที่แล้ว +4

    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.

  • @Đồnghồhữu-v4t
    @Đồnghồhữu-v4t 2 หลายเดือนก่อน

    thanks GS MALAN

  • @martijnb3381
    @martijnb3381 ปีที่แล้ว +1

    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.

    • @darksider6113
      @darksider6113 11 หลายเดือนก่อน +1

      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

    • @martijnb3381
      @martijnb3381 11 หลายเดือนก่อน

      @@darksider6113 Yes! If the parameter is a pointer (usually should be), then 'sizeof(pointer)' just alwas returns 4 or 8 Bytes.

  • @alefoelfo
    @alefoelfo ปีที่แล้ว +2

    We also want some snacks here!

  • @cameronvincent
    @cameronvincent ปีที่แล้ว +9

    just went outside no rubber duck was there false advertising

  • @abdullahiabdiaziz8197
    @abdullahiabdiaziz8197 ปีที่แล้ว +1

    Thanks ❤❤

  • @Adriel_rdj86
    @Adriel_rdj86 11 หลายเดือนก่อน

    lecture 2, gl to everyone

  • @ODAIR_SCTY_OFC
    @ODAIR_SCTY_OFC 11 หลายเดือนก่อน

    So good

  • @thewaterwasfine
    @thewaterwasfine 11 หลายเดือนก่อน +4

    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?

    • @ninevolt
      @ninevolt 11 หลายเดือนก่อน +3

      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!

    • @sharanyakaparthi4875
      @sharanyakaparthi4875 8 หลายเดือนก่อน

      ​@ninevolt tq I was having same doubt

  • @BaraaMansor
    @BaraaMansor 7 หลายเดือนก่อน

    Every time he says "see" i just say bun intended in my mind :D

  • @gablepeacock
    @gablepeacock ปีที่แล้ว +2

    On the example starting at 1:10:00, is “length” not supposed to be assigned a value?

    • @dzjin
      @dzjin ปีที่แล้ว

      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
      @ZeroZeppelin ปีที่แล้ว

      But whats the meaning of “length” in the function? Where is came from?

    • @ethansilverstein26
      @ethansilverstein26 11 หลายเดือนก่อน +1

      @@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.

  • @Jensmxksm
    @Jensmxksm 5 หลายเดือนก่อน

    This is like junior high no lie

  • @abdullah.astro1
    @abdullah.astro1 ปีที่แล้ว

    كورس فخم

  • @gabscar1
    @gabscar1 7 หลายเดือนก่อน +1

    Wish I knew debug50 when doing credit!

  • @MubashirShehzad
    @MubashirShehzad ปีที่แล้ว

    Thabk you

  • @AdrianLobodzinski
    @AdrianLobodzinski 3 หลายเดือนก่อน

    The intro reminds me of some TV series, like the Game of Thrones.

  • @Nrjrkeofhevdkendb
    @Nrjrkeofhevdkendb 11 หลายเดือนก่อน

    Respect

  • @MrSa30kumar
    @MrSa30kumar ปีที่แล้ว

    Yeahhhhhhh 🎉🎉🎉🎉🎉🎉

  • @shreyanshrajat783
    @shreyanshrajat783 7 หลายเดือนก่อน

    29:43 debugging

  • @ineedtobestudyingrightnow
    @ineedtobestudyingrightnow 9 หลายเดือนก่อน

    Personal Bookmark 48:00

  • @MatthewIrizarry-4
    @MatthewIrizarry-4 ปีที่แล้ว +8

    C doesn’t have a string type by default, it is implemented in the cs50.h file right?

    • @abhikpaul2526
      @abhikpaul2526 5 หลายเดือนก่อน

      yes it was implemented in the cs50.h file,

  • @zawepygler1223
    @zawepygler1223 9 หลายเดือนก่อน +1

    So anyone know what lightbulbs had encrypted in them? I don't think I can see the binary from the video.

  • @RoddPH
    @RoddPH 5 หลายเดือนก่อน +1

    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!

    • @Albertmars32
      @Albertmars32 5 หลายเดือนก่อน +1

      Bc name doesn't exist inside the function

    • @Gha_210
      @Gha_210 5 หลายเดือนก่อน +1

      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)

    • @Gha_210
      @Gha_210 5 หลายเดือนก่อน +1

      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

    • @RoddPH
      @RoddPH 5 หลายเดือนก่อน

      @@Gha_210 Thank you

    • @RoddPH
      @RoddPH 5 หลายเดือนก่อน

      @@Albertmars32 Thank you

  • @l30n.marin3r0
    @l30n.marin3r0 11 หลายเดือนก่อน +1

    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

  • @juli.72
    @juli.72 11 หลายเดือนก่อน

    35:56 that made me laugh so hard lol

  • @DannysDigisigns
    @DannysDigisigns 3 หลายเดือนก่อน

    @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 "
    "?

  • @youovercome
    @youovercome ปีที่แล้ว

    David J Malan is perfect person

  • @victorchukwugenem2390
    @victorchukwugenem2390 2 หลายเดือนก่อน

    in my line 7 its saying the name is unidentified

  • @MadhusudanSinha
    @MadhusudanSinha 5 หลายเดือนก่อน

    Array of sunshine.

  • @Abhinava_Playz_YT
    @Abhinava_Playz_YT 2 หลายเดือนก่อน

    51:03
    I literally counted it and it was 128
    I think it is 128GB RAM

  • @Peabea94
    @Peabea94 10 หลายเดือนก่อน

    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

  • @phellipecardoso8994
    @phellipecardoso8994 7 หลายเดือนก่อน

    01:13:59

  • @rishabhpurohit2663
    @rishabhpurohit2663 ปีที่แล้ว

    where is the value of int length declared? 1:13:20
    argc == 2? didn't get. 1:56:12

    • @lospokkes
      @lospokkes ปีที่แล้ว +1

      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"