C - Reading/Writing 2D Arrays

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

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

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

    Thank you so much for this video!

  • @GaryChike
    @GaryChike 2 ปีที่แล้ว

    Really good stuff! 🚀

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

      Thanks 😀

    • @GaryChike
      @GaryChike 2 ปีที่แล้ว

      @@PainlessProgramming could you tell me where I could find more info about that asterisk being used in the format specifier not to store the data? 😀

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

      @@GaryChike Yes, here is a good link with more details about scanf and format specifiers cplusplus.com/reference/cstdio/scanf/

    • @GaryChike
      @GaryChike 2 ปีที่แล้ว

      @@PainlessProgramming Excellent, thank you! 🙂

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

      @@PainlessProgramming gosh, after a year of additional study, I have yet to hear anyone mention 'sub-specifiers' for scanf(). I thought Claude3 did a great job explaining it. So, for those that are still learning like myself, here's a good explanation:
      "The * sub-specifier in scanf() is used to suppress the assignment of the matched input. When * is used immediately after the % character and before the conversion specifier (e.g., %*c, %*d, %*f), it indicates that the corresponding input should be read but not stored in any variable.
      In the given sample program, the line scanf("%f%*c", &grade[x]); is used to read a floating-point number followed by a newline character. Here's how it works:
      %f reads a floating-point number from the input and stores it in the grade[x] variable.
      %*c reads a single character from the input but doesn't store it anywhere. The * sub-specifier suppresses the assignment, so the character is consumed from the input stream but discarded.
      The purpose of using %*c in this case is to consume the newline character (
      ) that is typically entered by the user after inputting the grade. Without consuming the newline character, it would remain in the input buffer and potentially affect the next input operation.
      By using %*c, the program ensures that the newline character is consumed and discarded, preventing it from interfering with subsequent input operations. It's a useful feature that is often overlooked or not widely known."