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?
@@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.
@@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
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 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())) . .
This was the most helpful and straight forward c++ video I have used all semester, thank you
Glad you found it helpful and thanks for the comment and support.
Great tutorial!! Really helped me loop through and understand my assignment!!!
Glad it helped!
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?
Just iterate over the string, testing each character one at a time and report the results.
Finally understood thanks, professor
You are most welcome
Thanks a lot for your help!!!
Sir, do these function work on string literal of C++ or only on Null terminated C-style strings?
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?
@@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.
@@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
very helpful tnx
Glad it helped!
Good tutorial!
Glad it was helpful!
can we not use string in isdigit()
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])
@@ProfessorHankStalica how can we pass a string in this functions
@@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()))
.
.