C++ char data type and the difference between character and string literals [5]

Sdílet
Vložit
  • čas přidán 6. 06. 2023
  • Learn about the character data type and the difference between character and string literals in this C++ tutorial for beginners using Visual Studio 2022 C++ .
    // Learn more:
    CH02: Introduction to C++ ⇒ • CH02: Introduction to C++
    // Join the new Programming for Everyone Community Forum:
    professorhank.freeforums.net/
    // Consider supporting this channel in multiple ways
    paypal.me/hankstalica1
    Bitcoin: 177wfkQwzXiC8o2whQMVpSyuWUs95krKYB

Komentáře • 14

  • @Ayman-Elfky
    @Ayman-Elfky Před 2 měsíci

    thank you so much for this amazing vedio

  • @higiniofuentes2551
    @higiniofuentes2551 Před 10 měsíci

    Thank you for this very useful video!

  • @AnwarAliCodes
    @AnwarAliCodes Před 10 měsíci

    this was very helpful thank you :)

  • @gimpzilla
    @gimpzilla Před měsícem

    Is there a reason strings are preferred? My understanding is that you can set up a char *array[n size] and achieve similar results?

    • @ProfessorHankStalica
      @ProfessorHankStalica  Před měsícem

      Strings are easier to work with than arrays of characters. For one example, a < b is easier than strcmp(a, b) or a + b as opposed to strcat(a, b).
      Stuff like that.

  • @user-no9xf5ng4v
    @user-no9xf5ng4v Před měsícem

    Thx Bro, nice video! What is the IDE btw?

  • @higiniofuentes2551
    @higiniofuentes2551 Před 10 měsíci

    This is in C++. But what happens when a CSV file created by C++ contains strings, the store space is incremented by one per each string ?
    How Python read the CSV created before? It takes account of the \0 last character?

    • @ProfessorHankStalica
      @ProfessorHankStalica  Před 10 měsíci +1

      A CSV file is just a text file formatted a certain way. Either don't write \0 to the file or have your Python program deal with it when it reads the CSV file.

    • @higiniofuentes2551
      @higiniofuentes2551 Před 10 měsíci

      @@ProfessorHankStalica As you said a string created in C++, have a char \0 at the end => length+1 right?
      A string created in Python length = length right?
      CSV is a text file => 1 char = 1 byte then a CSV file created with C++ will have a char added to each string right?
      Then how I have to save the string to don't include a char \0 added from C++?
      Thank you!

    • @ProfessorHankStalica
      @ProfessorHankStalica  Před 10 měsíci +1

      @@higiniofuentes2551
      Here's an example:
      char str[] = "Hi";
      .
      .
      .
      fout