setw() not working for me

I'm using Dev C++ ver

This is the code:


int main() {
std::cout << "-" << 1 << "-";
return 0;

Here's a print screen of what happens when I try to run it:
Remove the setw(5); line. It only makes sense when it's inserted into an ostream (such as cout). That and it's part of the std namespace. Try this instead:

std::cout << std::setw(5) << "-" << 1 << "-";
Last edited on
Thanks so much for the input! Because that's the syntax given in the Visual Quickstart for C++. I used the "using namespace std;" and inserted it into an ostream as shacktar suggested.
Topic archived. No new replies allowed.