|
From: Per W. <pw...@ia...> - 2003-01-01 00:29:47
|
Just a note. On some systems, the case-insensitive function is named strcasecmp instead of stricmp. That's one of the reasons why people gets compile errors when trying to build wxWindows applications without using a correct project that defines what target to build for. /Per W On Tue, 31 Dec 2002, Abhijit Shylanath wrote: > TELSYS > Greets, Dondolo. > > ----- Original Message ----- > The problem I get is when evaluating my input, I get errors....c++ permits > me to evaluate a single character but not string of characters. > ---------------------------- > > Strings are actually arrays (which are actually pointers). So if you're > comparing these (remember that strings have to be put in quotes): > > char my_name[] = "Abhijit"; > char your_name[] = "Dondolo"; > > you would actually be comparing the pointers. You need to compare each > character. There is already a library function called strcmp(), which > compares them. > > strcmp(first, second) > > returns > 0 if first > second > < 0 if first < second > = 0 if first == second. > > stricmp() is the case-insensitive version. > > They're defined in <cstring>, and to access them, you would use the using > declaration: > > using std::strcmp; > using std::stricmp; // Whichever > > in the scope in which you want to use it (within the function, global, > etc.). > > So I would say, > > if(stricmp(my_name, your_name) == 0) > cout << "Hey, you're me!\n"; > > All this should have been written in the book you use (I assume you use a > book). If you don't have one, I suggest you get yourself a trustworthy book. > Post on this list for more info. Ioannis mentioned http://www.accu.org/ as a > site for reviews. I haven't seen it myself, I'm just recycling posts. Saving > the (integrated development) environment (mailing-list) and stuff... > > PS: It should be cin >> name, not <<. I think that was a typo. > > HTH. > And, yeah... Wish y'all a Happy New Year 2003. > > ___________________________________________________________ > > Abhijit Shylanath > > E-mail: mu...@gm... || ibr...@bi... > Web-site: http://mudeth.tripod.com/ > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |