Author: Steffen Jakob
Date: 02:38:27 01/24/03
Go up one level in this thread
On January 24, 2003 at 04:50:59, Odd Gunnar Malin wrote: >On January 24, 2003 at 03:22:37, Steffen Jakob wrote: > >>On January 24, 2003 at 03:15:55, Joshua Haglund wrote: >> >>>What do I need to #include to use strlen? >>>I've tried almost everything I can think of! >>>(C++) >> >>Don't use strlen() in C++ but std::string and its member function length(). :-) >> >>Greetings, >>Steffen. > >Sometimes you have to use routines from c's string.h, then to not confuse >yourself to much and also take care of std namespace, <cstring> should be used >instead of <string.h>. >The same goes for other (<ctime>, <cstdlib> etc...). > >A sample I use a lot is the following in the top of files. > >#ifdef _DEBUG > #define _CRTDBG_MAP_ALLOC > #include <cstdlib> > #include <crtdbg.h> >#endif > >Another could be if you want a case insensitive compare, then it's easier to use >cstring's stricmp instead of writing your own in c++. ... only if you are lucky and have "stricmp()" available on your system because it isn't part of the Ansi C standard. ;-) In Scott Meyers "Effective STL" you can read that to compare case-insensitive strings isn't sometimes as easy as one might think (e.g. if you compare non-english strings; in french 'é' might be treated equivalent to 'E'). He offers solutions for the trivial case as well for the advanced cases in his book (I strongly recommend to C++ programmers to read everything from Meyers). Greetings, Steffen.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.