注册 登录
编程论坛 VC++/MFC

简单的C++头文件问题~

小小小小小黄 发布于 2013-01-18 11:32, 607 次点击
cout<<setw(8)<<left<<a
这里面left的头文件是什么?

C:\Documents and Settings\小黄黄黄黄黄\桌面\C++程序题\ex4.cpp(9) : error C2065: 'left' : undeclared identifier
上面是编译提示的错误~
目的是让输出的数据靠左整齐~

8 回复
#2
qunxingw2013-01-18 11:59
iomanip

[ 本帖最后由 qunxingw 于 2013-1-18 12:10 编辑 ]
#3
羽VS翼2013-01-18 15:32
#include<iomanip.h>
#4
小小小小小黄2013-01-18 22:16
回复 楼主 小小小小小黄
//斐波那契数列。输出斐波那契数列的前40项。
//斐波那契数列数列的特征是:前两项为1,以后每一项为前两项只和。
#include<iostream.h>
#include<iomanip.h>

void main()
{
    int a=1,b=1,c;
    cout<<setw(8)<<left<<a
        <<setw(8)<<left<<b;
    for(int i=1;i<=38;i++)
    {
        c=a+b;
        a=b;
        b=c;
        cout<<setw(8)<<left<<c;
    }
}


编译时的错误:
c:\documents and settings\小黄黄黄黄黄\桌面\c++程序题\ex4.cpp(9) : error C2065: 'left' : undeclared identifier
Error executing cl.exe.
#5
小小小小小黄2013-01-18 22:17
回复 3楼 羽VS翼
//斐波那契数列。输出斐波那契数列的前40项。
//斐波那契数列数列的特征是:前两项为1,以后每一项为前两项只和。
#include<iostream.h>
#include<iomanip.h>

void main()
{
    int a=1,b=1,c;
    cout<<setw(8)<<left<<a
        <<setw(8)<<left<<b;
    for(int i=1;i<=38;i++)
    {
        c=a+b;
        a=b;
        b=c;
        cout<<setw(8)<<left<<c;
    }
}


编译时的错误:
c:\documents and settings\小黄黄黄黄黄\桌面\c++程序题\ex4.cpp(9) : error C2065: 'left' : undeclared identifier
Error executing cl.exe.
#6
小小小小小黄2013-01-18 22:17
回复 2楼 qunxingw
//斐波那契数列。输出斐波那契数列的前40项。
//斐波那契数列数列的特征是:前两项为1,以后每一项为前两项只和。
#include<iostream.h>
#include<iomanip.h>

void main()
{
    int a=1,b=1,c;
    cout<<setw(8)<<left<<a
        <<setw(8)<<left<<b;
    for(int i=1;i<=38;i++)
    {
        c=a+b;
        a=b;
        b=c;
        cout<<setw(8)<<left<<c;
    }
}


编译时的错误:
c:\documents and settings\小黄黄黄黄黄\桌面\c++程序题\ex4.cpp(9) : error C2065: 'left' : undeclared identifier
Error executing cl.exe.
#7
小小小小小黄2013-01-18 22:18
之前考试的时候用到了left 左对齐,头文件也是打出了iomanip.h
现在又出现问题了,小白求教~~

#8
wp2319572013-01-19 03:48
程序代码:
#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
    int a=1,b=1,c;
    cout<<setw(8)<<left<<a
        <<setw(8)<<left<<b;
    for(int i=1;i<=38;i++)
    {
        c=a+b;
        a=b;
        b=c;
        cout<<setw(8)<<left<<c;
    }
#9
小小小小小黄2013-01-19 20:16
回复 8楼 wp231957
求解释~
为什么~

1