Hello guys, i am a beginner at programing, and I found this site really helpful as it has c++ tutorials, all the libraries and its functions with example code, and the forums. I been trying to change upper case letters to lower case, first i did it with type casting and the ASCII code, but I found that it was possible with the library ctype, but I don't understand any of the example codes, are they in C? I program in bloodshed dev-C++.
My questions are: what do u recomend me to understand the examples that are around the libraries explanation? make the tutorials? Because i program differently from the examples; and how can I change upper to lower case letters using the ctype library, using tolower?
Not sure what's ur doubt.
You already have what you want:
Just include this librabry <cctype>
and when you want to change the case of any character,simply use tolower and toupper function and pass that character as an argument.
#include <cstdlib>
#include <iostream>
#include <cctype>
#include <cstring>
usingnamespace std;
int main(int argc, char *argv[])
{
char A[20];
cin>>A;
cout<<endl;
// for (int b=0; b<=strlen(A); b++) // loops too far
for (int b=0; b < strlen(A); b++) // b < strlen(A) is correct
{
// tolower(A[b]); // this doesn't change the value
A[b] = tolower(A[b]); // need to assign the output of tolower()
cout<<A[b];
}
cout<<endl;
string trash;
getline(cin, trash);
getline(cin, trash);
return EXIT_SUCCESS;
}
Also you might want to look at the std C++ libraries for this too: