C++ Tutorial: Testing Characters Using the cctype library

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

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

  • @allusivestorm762
    @allusivestorm762 2 года назад +2

    This was the most helpful and straight forward c++ video I have used all semester, thank you

    • @ProfessorHankStalica
      @ProfessorHankStalica  2 года назад

      Glad you found it helpful and thanks for the comment and support.

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

    Great tutorial!! Really helped me loop through and understand my assignment!!!

  • @Genoprototype
    @Genoprototype 3 года назад +2

    This was really useful, thank you!
    Btw how would you be able to have the user input a string and then display what each type of character is?

    • @ProfessorHankStalica
      @ProfessorHankStalica  3 года назад +2

      Just iterate over the string, testing each character one at a time and report the results.

  • @avg_user-dd2yb
    @avg_user-dd2yb 3 года назад +1

    Finally understood thanks, professor

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

    Thanks a lot for your help!!!

  • @akmansr7149
    @akmansr7149 3 года назад +1

    Sir, do these function work on string literal of C++ or only on Null terminated C-style strings?

    • @ProfessorHankStalica
      @ProfessorHankStalica  3 года назад +1

      Hi ya..not sure if I understand the question because a string literal in C++ is a null terminated C-style string. That's how they are represented in memory.
      It's like asking, does this only work for a variable or does it work for a variable?

    • @akmansr7149
      @akmansr7149 3 года назад

      @@ProfessorHankStalica I'm sorry. i meant, in c++ we use *data-type* string (string name) and in C-style string we used to use char array[ ]. So, my question is does cctype function work on the string data type that comes with #include header file.

    • @ProfessorHankStalica
      @ProfessorHankStalica  3 года назад

      @@akmansr7149 You would need to convert a string object into a c-string first. You can use the c_str() method for string objects. Although, later versions of C++ support equivalent versions of cctype for string objects. I have a video on it which can give you an idea: ruclips.net/video/Pvym4UDZJ8k/видео.html

  • @eyout7973
    @eyout7973 3 года назад +2

    very helpful tnx

  • @paulharman2099
    @paulharman2099 3 года назад +1

    Good tutorial!

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

    can we not use string in isdigit()

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

      No, isdigit() only accepts characters. It's a character testing function, not a string-testing function.
      Pretty sure you can pass it an element of a string though..
      string s = "12345";
      .
      .
      .
      isdigit(s[2])

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

      @@ProfessorHankStalica how can we pass a string in this functions

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

      @@BuCz2004 If you have a string variable named foo and you want to pass it as an argument to one of these functions, use the string's c_str method. So, for example:
      string foo;
      .
      .
      .
      if(isdigit(foo.c_str()))
      .
      .