Convert character cases using toupper and tolower

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025

Комментарии •

  • @M7medKasem
    @M7medKasem 11 месяцев назад +1

    if nobody said it today, thanks professor hank.

  • @Khayyyem
    @Khayyyem Год назад

    thank you so much for these videos. with finals coming up these videos are so helpful to learn material I never understood in class!

  • @qcnck2776
    @qcnck2776 Год назад +1

    The upper() function takes the str[] array and changes the values of the characters stored in it since str is just a pointer. So, is it correct to think of passing an array to a function as implicitly passing by-reference?
    But if one were to pass a string class variable to a function (e.g string myString), one would have to explicitly pass it by-reference (string&)?

    • @ProfessorHankStalica
      @ProfessorHankStalica  Год назад +2

      Right both times.
      The only way to pass an array is by reference, it's because an array is a constant pointer so you are actually copying the memory address to the parameter, just like with pass-by-reference.
      Since a string is actually an object, it gets copied to the parameter like an int would (sort of). So, if you want to modify the argument, you have to pass a string variable by reference.
      100% correct.

  • @faizaniftikhar
    @faizaniftikhar Год назад

    Hi professor,
    I'm trying to make a function where I send a c-string as a literal and it returns the lowercase string.
    something like this:
    cout

    • @ProfessorHankStalica
      @ProfessorHankStalica  Год назад +1

      Sure. You should be able to. Just double check that the dynamically allocated array has enough room. I can't remember if strlen counts the null terminator or not, but I don't think it does.
      Also, if your parameter gives you problems, you could use const char* str instead.