| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 821 人关注过本帖
标题:error C2017 C2001等求助
只看楼主 加入收藏
熙仔轩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2009-7-28
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
error C2017 C2001等求助
#include<iostream>

int Double(int);
long Double(long);
float Double(float);
double Double(double);

using namespace std;

int main()
{
    int myInt=6500;
    long myLong=65000;
    float myFloat=6.5F;
    double myDouble=6.6e20;

    int doubledInt;
    long doubledLong;
    float doubledFloat;
    double doubledDouble;

    cout<<"myInt: "<<myInt<<"\n";
    cout<<"myLong: "<<myLong<<"\n";
    cout<<"myFloat: "<<myFloat<<"\n";
    cout<<"myDouble: "<<myDouble<<"\n";
    
    doubledInt=Double(myInt);
    doubledLong=Double(myLong);
    doubledFloat=Double(myFloat);
    doubledDouble=Double(myDouble);

    cout<<"doubledInt: "<<doubledInt<<"\n";
    cout<<"doubledLong: "<<doubledLong<<"\n";
    cout<<"doubledFloat: "<<"doubledFloat<<"\n";
    cout<<"doubledDouble: "<<"doubledDoule<<"\n";

    return 0;
}

int Double(int original)
{
    cout<<"In Double(int)\n";
    return 2*original;
}

long Double(long original)
{
    cout<<"In Double(long)\n";
    return 2*original;
}

float Double(float original)
{
    cout<<"In Double(float)\n";
    return 2*original;
}

double Double(double original)
{
    cout<<"In Double(double)\n";
    return 2*original;
}


错误
--------------------Configuration: hello1 - Win32 Debug--------------------
Compiling...
hello1.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(34) : error C2017: illegal escape sequence
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(34) : error C2001: newline in constant
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(34) : error C2146: syntax error : missing ';' before identifier 'n'
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(34) : error C2065: 'n' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(34) : error C2143: syntax error : missing ';' before 'string'
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(35) : error C2146: syntax error : missing ';' before identifier 'cout'
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(35) : error C2017: illegal escape sequence
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(35) : error C2001: newline in constant
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(35) : error C2146: syntax error : missing ';' before identifier 'n'
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(35) : error C2143: syntax error : missing ';' before 'string'
C:\Program Files\Microsoft Visual Studio\MyProjects\hello1\hello1.cpp(37) : error C2143: syntax error : missing ';' before 'return'
执行 cl.exe 时出错.

hello1.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: include double 
2009-08-05 13:33
zmq
Rank: 2
等 级:论坛游民
帖 子:20
专家分:20
注 册:2008-11-2
收藏
得分:0 


根据软件的中文错误信息提示调试通过的程序如下:
/* Note:Your choice is C IDE */
#include<iostream>

int Double(int);
long Double(long);
float Double(float);
double Double(double);

using namespace std;

int main()
{
    int myInt=6500;
    long myLong=65000;
    float myFloat=6.5F;
    double myDouble=6.6e20;

    int doubledInt;
    long doubledLong;
    float doubledFloat;
    double doubledDouble;

    cout<<"myInt: "<<myInt<<"\n";
    cout<<"myLong: "<<myLong<<"\n";
    cout<<"myFloat: "<<myFloat<<"\n";
    cout<<"myDouble: "<<myDouble<<"\n";
   
    doubledInt=Double(myInt);
    doubledLong=Double(myLong);
    doubledFloat=Double(myFloat);
    doubledDouble=Double(myDouble);

    cout<<"doubledInt: "<<doubledInt<<"\n";
    cout<<"doubledLong: "<<doubledLong<<"\n";
    cout<<"doubledFloat: "<<doubledFloat<<"\n";   
    cout<<"doubledDouble: "<<doubledDouble<<"\n";

    return 0;
}

int Double(int original)
{
    cout<<"In Double(int)\n";
    return 2*original;
}

long Double(long original)
{
    cout<<"In Double(long)\n";
    return 2*original;
}

float Double(float original)
{
    cout<<"In Double(float)\n";
    return 2*original;
}

double Double(double original)
{
    cout<<"In Double(double)\n";
    return 2*original;
}

[[it] 本帖最后由 zmq 于 2009-8-5 16:42 编辑 [/it]]

tc.jpg (57.46 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
2009-08-05 16:33
zmq
Rank: 2
等 级:论坛游民
帖 子:20
专家分:20
注 册:2008-11-2
收藏
得分:20 
其中
C2017 非法转义序列,也就是
此后语句 cout<<"doubledFloat: "<<"doubledFloat<<"\n"; 的"doubledFloat多了一个引号。
C 2001 常数中有换行符 也是由于上述原因引起的。

另外cout<<"doubledDouble: "<<"doubledDoule<<"\n"; 中的"doubledDoule 去掉"  ,doubledDoule漏写了b即doubledDouble




2009-08-05 16:54
熙仔轩
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2009-7-28
收藏
得分:0 
谢谢啊
2009-08-06 23:28
快速回复:error C2017 C2001等求助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015773 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved