Advertisement
char * strlwr(char *str);
// Program to convert a String to lower case letters
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char str1[] = "HURRAY! Victory!";
cout<< "Original String value : " << str1 << "\n";
strupr(str1);
cout<< "String's upper case value : " << str1;
return 0;
}
Original string value : HURRAY! Victory!
String's upper case value : hurray! victory!
Advertisement
// Program to convert a string to lower case letters withut strlwr() function
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char str[] = "Never Give Up!";
cout<< "Original String is : " << str <<"\n";
// starting index in a char{} array is always zero, 0
int i=0;
while(str[i]!='\0')
{
int asc = str[i];
// When ASCII value of a space is found
if(asc==32)
{
// we don't do anything
}
// When alphabetic characters are found
if(asc>=65 && asc<=90)
{
asc = asc + 32;
str[i] = asc;
}
// incrementing the index to point to next char value in string
i++;
}
cout<<"String's lower case value : " << str;
return 0;
}
Original String is : Never Give Up!
String's lower case value : never give up!
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement