iomanip: setwidth was not declared in this scope

V

Vaxius

After trying to compile the following code, gcc gives me

error: 'setwidth' was not declared in this scope

I'm not sure why it would do this, since iomanip is included. Am I missing
something?

code:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int checkPoint(int, int);

int main()
{
int n, i, j, icount;

cout << "Number of possible moves for a knight on a chess board\n\n";

for (j = 1; j <= 8; j++)
{
for (i = 1; i <= 8; i++)
{
icount = checkPoint(i, j);

cout << setwidth(5) << icount;
}
cout << endl;
}
}

int checkPoint(int i, int j)
{
int icount, p, k, n, m;

icount = 0;
p = -1;

for (k = -2; k <= 2; k++)
{
if (k != 0)
{
for (n = 1; n <= 2; n++)
{
p = -p;
m = p * (3 - abs(k));

if (1 <= (i + k) && (i + k) <= 8 && 1 <= (j + m) && (j + m)
<= 8) icount++;
}
}
}
return icount;
}
 
V

Vaxius

Forgot some important information. I'm using Code::Blocks on a Kubuntu
Dapper system. gcc 4.0.3
 
Z

Zara

After trying to compile the following code, gcc gives me

error: 'setwidth' was not declared in this scope

I'm not sure why it would do this, since iomanip is included. Am I missing
something?
<..>

NMaybe you are trying to use std::setw not std::setwidth


Zara
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top