Terms of Agreement:
By using this code, you agree to the following terms...
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
//**************************************
//
// Name: String Lower Function
// Description:I found that on some unix
// systems the string.h header file didn't
// have strlwr, strrev, strupr within them.
// So I had to come up with a string lower
// function for this. I thought that I woul
// d post this in hopes that if any of you
// have this trouble you can have a way to
// lowercase a string fast. reliably. and q
// uickly.
// By: Shawn Elliott
//
// Inputs:a string
//
// Returns:lower case string or word
//
//This code is copyrighted and has// limited warranties.Please see http://
// www.1CPlusPlusStreet.com/xq/ASP/txtCodeI
// d.300/lngWId.3/qx/vb/scripts/ShowCode.ht
// m//for details.//**************************************
//
#include "string.h"
#include "iostream.h"
char* stringlower(char*);
int main()
{
char* str = "HELLO";
cout << "String was : " << str << "\n";
str = stringlower(str);
cout << "String is now : " << str << "\n"; //print this to STDOUT
return 0;
}
//
//this function is the part that does th
// e string lowering work.
//
char* stringlower(char* incString)
{
//this sub checks the case of each lette
// r of the Word. It then converts any Capi
// tol letters to lower case.
char lowerstring[250];
int Chr;
int Diff = 'a' - 'A'; //this is the integer difference between the two cases.
strcpy(lowerstring,incString);
for (int i = 0; i <= strlen(lowerstring); i++)
{
if (i > 250) break;
if (lowerstring[i] >= 65 && lowerstring[i] <= 90)
{
//this character is a capital
//thus add the difference to the string.
//
//this will now make the uppercase letter into lowercase.
Chr = lowerstring[i] + Diff;
lowerstring[i] = Chr;
}
}
return lowerstring; //return the lower case word
} //end of convertCase