标题:求解,华氏度与摄氏度的相互转换的程序提示错误
取消只看楼主
xzq19960823
Rank: 1
来 自:浙江
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-7-14
 问题点数:0 回复次数:1 
求解,华氏度与摄氏度的相互转换的程序提示错误
程序代码:
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
void mutual(char* val)
{
    unsigned int x;
    char l_s;
    double a_s,c_s;
    x=unsigned int strlen(const char* val);
    l_s=*(val+x-1);
    a_s=double atof(*(val+x-2));
    if(l_s=='C'||l_s=='c')cout<<"Degrees Fahrenheit"<<a_s*9/5+32<<"F"<<endl;
    else if(l_s=='F'||l_s=='f')cout<<"Degrees Celsius"<<5/9*(a_s-32)<<"C"<<endl;
    else cout<<"Please enter the correct temperature."<<endl;
}
int main()
{
    char value;
    cout<<"Please enter the fahrenheit or celsius.Remember plus unit."<<endl;
    cin.get(value);
    mutual(&value);
    return 0;
}

--------------------Configuration: text3 - Win32 Debug--------------------
Compiling...
text3.cpp
F:\VC Class\3rd\text3.cpp(10) : error C2062: type 'unsigned int' unexpected
F:\VC Class\3rd\text3.cpp(12) : error C2062: type 'double' unexpected
Error executing cl.exe.

text3.exe - 2 error(s), 0 warning(s)

[此贴子已经被作者于2016-7-14 09:35编辑过]

搜索更多相关主题的帖子: 摄氏度 华氏度 
2016-07-14 09:33
xzq19960823
Rank: 1
来 自:浙江
等 级:新手上路
帖 子:2
专家分:0
注 册:2016-7-14
得分:0 
回复 2楼 U201010009
括起来了,然后提示了这个
--------------------Configuration: text3 - Win32 Debug--------------------
Compiling...
text3.cpp
F:\VC Class\3rd\text3.cpp(10) : error C2143: syntax error : missing ')' before 'const'
F:\VC Class\3rd\text3.cpp(10) : error C2660: 'strlen' : function does not take 0 parameters
F:\VC Class\3rd\text3.cpp(10) : error C2059: syntax error : ')'
F:\VC Class\3rd\text3.cpp(12) : error C2664: 'atof' : cannot convert parameter 1 from 'char' to 'const char *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

text3.exe - 4 error(s), 0 warning(s)

好好学习,天天向上。
2016-07-14 10:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-466906-1-1.html




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

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