Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
iomanip: setwidth was not declared in this scope
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Vaxius, post: 2554881"] 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; } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
iomanip: setwidth was not declared in this scope
Top