Skip to main content
gamedev.net
🔒 Locked

Strings... lowercase

Started by Kelendil 9 replies 850+ views
Original Post
Kelendil
Kelendil
I have an assignment where I must determine if a sentence is a palindrome, using strings. I use
        
#include <string>
using namespace std;
    
Anyone know a function to turn strings to lowercase? Edited by - Kelendil on 10/25/00 1:31:04 PM
Kelendil
Kelendil
heh.. there was supposed to be an enter key before "using namespace std;"... how do you include spacing?
Ironblayde
Ironblayde
int tolower( int c );

This converts a character to lowercase. It''s in stdlib.h.

-Ironblayde
 Aeon Software

The following sentence is true.
The preceding sentence is false.
"Your superior intellect is no match for our puny weapons!"
Zordan Ehrwald
Zordan Ehrwald
Just use _strlwr ... it converts a full string to lowercase.
Syntax is :
_strlwr(LPSTR szString);

where szString is your string you want to convert.

... so why don't you come here ? You realy should come.

http:\\zordan.gnw.de
So why don't you come here?<br/>You realy should come.
CobraA1
CobraA1
_strlwr will only work in VC++, and you are probably learning ANSI C++, so you don''t want to do that in your class. Otherwise, you''ll be learning something that will not work sometimes.

Use tolower; you can make your own function to convert a whole string.



"Whoever performs only his duty is not doing his duty." --Bahya ibn Pakuda
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away"--Henry David Thoreau
nes8bit
nes8bit
If you''re leeb then you can use lcase$()

---------------------------
Tell your friends. Tell your family. Tell your...don't tell your family. The GDTalker
Zordan Ehrwald
Zordan Ehrwald
_strlwr(char* string);

is defined in string.h and
is definitly not only part of vc++ but
part of the Ansi C specs.

... so why don't you come here ? You realy should come.

http:\\zordan.gnw.de
So why don't you come here?<br/>You realy should come.
CobraA1
CobraA1
Well, it''s not in my books. Can you point me to a place where I can view the ANSI specs? It seems you must have them with you.



"Whoever performs only his duty is not doing his duty." --Bahya ibn Pakuda
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away"--Henry David Thoreau
Muzzafarath
Muzzafarath
I can't find the _strlwr() function in my books or online docs either. Functions starting with an underscore are _usually_ compiler-specific. I'd also like to know where you've found out that _strlwr() is part of the ANSI C standard

Edited by - Muzzafarath on October 30, 2000 11:19:14 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
furby100
furby100
Upon inspection of _both_ the C, C89 and C99 ANSI/ISO standards, that function does not exist. Therefore, I conclude it is not part of any ANSI/ISO standard.



Please state the nature of the debugging emergency.


sharewaregames.20m.com

Zordan Ehrwald
Zordan Ehrwald
Dang you are right ... this text fragment is taken from the
DJGPP C Library Reference :

strlwr

Syntax
#include

char *strlwr(char *string);

Description
This function replaces all upper case letters in string with lower case letters.

Return Value
The string.

Portability
not ANSI, not POSIX

Example
char buf[100] = "Hello";
strlwr(buf);

So I hope you take my excuse

P.S. The function is available for most (I don''t know any whitout) compilers anyway >:>

... so why don't you come here ? You realy should come.

http:\\zordan.gnw.de
So why don't you come here?<br/>You realy should come.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.