Archived

This topic is now archived and is closed to further replies.

Nibbles

String manipulation

Recommended Posts

Nibbles    569
Hi, Anybody know of any good resources about string manipulation? For example, justifing strings, parsing for certain words/characters. Stuff like that. Java would be ideal, but C/C++ is welcome too. Thanks, Scott

Share this post


Link to post
Share on other sites
jenova    122
for parsing strings; in "C" you can use the "strtok" function. for justification you may want to look into the "sprintf" function.

"SDL" evangelists will probably suggest the "string" class. i don''t know, because i don''t use SDL.

i, presonally created my own string class to handle this behaviour due to speed restrictions.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
Oluseyi    2109
quote:
Original post by jenova
"SDL" evangelists will probably suggest the "string" class. i don''t know, because i don''t use SDL.

I''m sure you mean STL (Standard Template Library) as opposed to SDL (Simple DirectMedia Library)

Anyway, look into strtok and snprintf (the difference in names could save you from being hacked; snprintf is more secure than sprintf - less susceptible to buffer overrun exploits) for C. In C++, look into std::string (header file: <string>), paying particular attention to it''s find_first_of, find_last_of, find_first_not_of and find_last_not_of methods, as well as std::stringstream (header: <sstream>. You might also want to look into I/O manipulators (header: <iomanip>).

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
jenova    122
lol. yes, i meant STL.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites