Works for me :confused:
Printable View
Works for me :confused:
1. First tell us the error :rolleyes:
2. Try including <ctype.h>
I want to transform I into lowercase
as if I is an CIN from the user.
Please give advice
I'm not really following. You cin a char into I, say 'V', and tolower() makes it lower case. It works for me.Quote:
Originally posted by prog_tom
I want to transform I into lowercase
as if I is an CIN from the user.
Please give advice
Can you post the code of getting lowercase of a CIN? Thanks
your code works for me.Code:#include <iostream>
#include <time.h>
#include <math.h>
using namespace std;
char I;
void main()
{
system("cls");
cin >> I;
I = tolower(I);
cout << "\n\tWelcome to this hot stuff! " << I << endl;
system("pause");
exit(0);
}
:)
But only 1 letter...
I want it to do it for up to 256 chars
It will work for all the upper case letters. I think, I is confusing you. Use this code:Quote:
Originally posted by prog_tom
I want it to do it for up to 256 chars
VB Code:
#include <iostream> #include <time.h> #include <math.h> using namespace std; char word; void main() { system("cls"); cin >> word; word = tolower(word); cout << "\n\tWelcome to this hot stuff! " << word << endl; system("pause"); exit(0); }
Now, if you type "A", it`s gonna print ``a``. Samething for all the other letters.
If you want to uppercase a whole C style string you can iterate trough the array and lowercase each letter
char I[256],*i;
cin >> I;
for(i=I;*i;*i++=tolower(*i));
that's pretty it the easiest solution..........just use the for loop or any other iteration command
keda, this is the most confusing code I've EVER EVER seen! Such things easily fall to the postfix/prefix trap! I don't fear that you'll ever fall into it, but it can easily hit others in snippets like this...
I know the operator presedence pretty well :D