头文件:在VC6.0可以是ctype.h或者stdlib.h,常用ctype.h
用 法: int tolower(int c);
说明:和函数int _tolower( int c );功能一样,但是_tolower在VC6.0中头文件要用ctype.h
C程序例:
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
int main()
{
int length, i;
char string[]="THIS IS A STRING";
length=strlen(string);
printf("%s\n",string);
for(i=0;i<length;i++)
{
string[i] = tolower(string[i]);
}
printf("%s\n",string);
system("pause");
}
c++程序例:
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string str= "THIS IS A STRING";
for (int i=0; i <str.size(); i++)
{
str[i] = tolower(str[i]);
}
cout<<str<<endl;
return 0;
}