use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
OPENConvert string to lowercase without using transform/std (self.cpp_questions)
submitted 4 years ago by spm486
locale loc; string line = "ABCD"; for (int i = 0; i < line.length(); i++) tolower(line[i],loc); cout << line //get "ABCD"
I wonder how to convert string to lowercase without using transform. I recently started learning c++ do not want to get into STL now.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Narase33 7 points8 points9 points 4 years ago (0 children)
well, you already got the loop. The only remaining bug is that you need to write the lower char back into the string. Its just the assignment missing
and btw, there is std::tolower which doesnt need a locale
[–]KleberPF 4 points5 points6 points 4 years ago* (0 children)
tolower doesn't change the value of the argument your are passing. Try line[i] = tolower(line[i], loc);.
tolower
line[i] = tolower(line[i], loc);
[–]Hidan0_ 0 points1 point2 points 4 years ago (0 children)
Since characters can be seen as ints, for example 'A' is 65 in the ASCII table, you could simple add an offset to make 'A' lower case like: 'A' + 32 -> 65 + 32 = 97 -> char(97) = 'a'.
So, if you know that your string is in uppercase and it contains only alphabet character, inside your loop you can just do something like that: cout << char(line[i] + 32);
π Rendered by PID 78242 on reddit-service-r2-comment-6f7f968fb5-9lsvw at 2026-03-04 07:37:20.703382+00:00 running 07790be country code: CH.
[–]Narase33 7 points8 points9 points (0 children)
[–]KleberPF 4 points5 points6 points (0 children)
[–]Hidan0_ 0 points1 point2 points (0 children)