setw() not working for me

I'm using Dev C++ ver 4.9.9.2

This is the code:

#include<iostream>
#include<iomanip>

int main() {
setw(5);
std::cout << "-" << 1 << "-";
std::cin.get();
return 0;
}

Here's a print screen of what happens when I try to run it:
http://s723.photobucket.com/albums/ww234/padfoots666/?action=view&current=1.png
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.