What is the equivalent of toupper, strcpy and strtok in C++ ?
What is the equivalent of toupper, strcpy and strtok in C++ ?
toupper, strcpy and strtok.Originally posted by Max
What is the equivalent of toupper, strcpy and strtok in C++ ?
Quzah.
Hope is the first step on the road to disappointment.
std::string::find() would be functionally equivalent to strtok()
and the assignment operators, constructors of the std::string class take care of strcpy.
i'm not aware of any toupper() in the std::string type.
There is no toupper in the std::string type. You can use the toupper in cctype (ctype.h). In stead of a for loop you can use the transform function in algorithm:Originally posted by Eibro
i'm not aware of any toupper() in the std::string type.
Code:#include <string> #include <cctype> #include <algorithm> #include <iostream> int main(void) { std::string msg = "Hello world"; std::transform(msg.begin(), msg.end(), msg.begin(), toupper); std::cout << msg << '\n'; }
if you use MSVC
CharUpper()
PHP and XML
Let's talk about SAX
I couldn't find any toupper()/tolower() func so so I just wrote my own works fine for me
the words of a true noob.Originally posted by face_master
I couldn't find any toupper()/tolower() func so so I just wrote my own works fine for me
hello, internet!
Noobs dont often write their own functions. They dont know how Besides, you learn a lot more that way toothe words of a true noob.
IDE: Dev C++ 5
Lib: Allegro
OS: Windows 2000
I'm with you, face_master. I have more fun writing my own function anyway. I've done my own isdigit, atoi, and strlen functions. I don't really like using library functions because I don't know how those functions work. That's one thing I don't like about data encapsulation——being kept in the dark about how everything works.Originally posted by face_master
I couldn't find any toupper()/tolower() func so so I just wrote my own works fine for me
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
>That's one thing I don't like about data encapsulation——being kept in the dark about how everything works.
That's the reason for encapsulation . But you can find implementations of the standard C library if you expend a small amount of energy looking.
>I couldn't find any toupper()/tolower() func
Try <cctype> or <ctype.h>. If they're not there then your compiler has issues.
-Prelude
My best code is written with the delete key.