Home C++ Iostream Functions nouppercase C++ nouppercase Manipulator Definition In C++, nouppercase turns off uppercase. After it, hexadecimal digits print as a to f, and scientific notation uses a small e.
This is the default, so it matters only after you used uppercase. It comes from <ios>, which <iostream> includes.
This is a manipulator . You do not call it on its own. You send it into a stream with << or >>, and it changes how that stream behaves from then on (or does one small job, like ending a line).
Syntax Put std::nouppercase into the stream.
std::cout << std::hex << std::uppercase << 255; // FF
std::cout << std::nouppercase << 255; // ff Call What it does std::cout << std::nouppercaseSmall letters in numbers from now on. std::cout << std::hex << std::nouppercase << 255Prints ff. std::cout << std::scientific << std::nouppercase << 1500.0Prints 1.500000e+03.
It has no effect on text. It changes only letters that belong to numbers.
Library declarations ios_base& nouppercase(ios_base& str); Parameters Parameter Description strThe stream. It is passed in for you when you write cout << nouppercase. You never write this argument yourself.
Return Value Return Value Description ios_base&A reference to the same stream, so you can keep chaining << or >> after nouppercase.
C++ Examples 1. Back to lower case 2. Exponent letter 3. A hex word Example 1 — Switch Hex Back to Small Letters Print one value, change the setting, and print it again.
#include <iostream>
int main() {
std::cout << std::hex << std::uppercase << 255 << '\n';
std::cout << std::nouppercase << 255 << '\n';
return 0;
} How It Works With hex and uppercase, 255 prints as FF. nouppercase turns the capitals off, but hex stays on.The second line prints the same number as ff. Example 2 — Lower-Case e in Scientific Notation The exponent letter changes back from E to e.
#include <iostream>
int main() {
std::cout << std::scientific << std::uppercase << 12345.678 << '\n';
std::cout << std::nouppercase << 12345.678 << '\n';
return 0;
} 1.234568E+04
1.234568e+04 How It Works scientific with uppercase prints the exponent as E.nouppercase comes in the middle of the second statement and turns the capital off.The same number now prints with a small e. Example 3 — Print a Word in Hex Both Ways BEEF and beef are the same number written two ways.
#include <iostream>
int main() {
int value = 48879;
std::cout << std::hex;
std::cout << std::uppercase << value << ' ';
std::cout << std::nouppercase << value << '\n';
return 0;
} How It Works hex is set once at the top and stays on.The first value is printed with capitals: BEEF. nouppercase is put in before the second one, which prints as beef. Both mean 48879.Frequently Asked Questions What does nouppercase do in C++? It turns off uppercase, so hex digits and the e of scientific notation are printed in small letters.
Is nouppercase the default? Yes. Numbers print with small letters unless you turn uppercase on.
Does nouppercase change text? No. It only changes letters that are part of printed numbers.
How do I print hex in small letters again? Put std::nouppercase into the stream. The base stays hex until you change it.
What is the same as nouppercase? cout.unsetf(std::ios::uppercase) has the same effect.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
14 people found this page helpful
Helpful Share Copy link Suggestion