鱼C论坛

 找回密码
 立即注册
查看: 1412|回复: 5

[已解决]小白一只,这样打为什么会出错,求解

[复制链接]
发表于 2017-7-12 18:45:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <stdio.h>
#include<stdio.h>


void main()
{
     double  x,s;
         printf("input number:\n");
         scanf("%lf",&x);
         s=sin(x);
         printf(sine of %lf is %lfln",x,s);



}
--------------------Configuration: Hello  worid - Win32 Debug--------------------
Compiling...
Hello worid.c
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(10) : warning C4013: 'sin' undefined; assuming extern returning int
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2065: 'sine' : undeclared identifier
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : warning C4024: 'printf' : different types for formal and actual parameter 1
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2146: syntax error : missing ')' before identifier 'of'
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2001: newline in constant
执行 cl.exe 时出错.

Hello worid.obj - 1 error(s), 0 warning(s)
最佳答案
2017-7-12 19:10:52

少了个双引号:

  1. #include <stdio.h>
  2. #include <math.h>

  3. int main(void)
  4. {
  5.          double x, s;

  6.          printf("input number:\n");
  7.          scanf("%lf",&x);
  8.          s = sin(x);
  9.          printf("sine of %lf is %lf\n",x,s);
  10. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-7-12 18:46:30 | 显示全部楼层
  1. #include <stdio.h>
  2. #include <math.h>

  3. int main(void)
  4. {
  5.          double x, s;

  6.          printf("input number:\n");
  7.          scanf("%lf",&x);
  8.          s = sin(x);
  9.          printf(sine of %lf is %lf\n",x,s);
  10. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2017-7-12 19:08:00 | 显示全部楼层

#include <stdio.h>
#include <math.h>

int main(void)
{
         double x, s;

         printf("input number:\n");
         scanf("%lf",&x);
         s = sin(x);
         printf(sine of %lf is %lf\n",x,s);
}

--------------------Configuration: Hello  worid - Win32 Debug--------------------
Compiling...
Hello worid.c
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2065: 'sine' : undeclared identifier
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : warning C4024: 'printf' : different types for formal and actual parameter 1
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2146: syntax error : missing ')' before identifier 'of'
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2017: illegal escape sequence
E:\Microsoft Visual Studio\MyProjects\Hello  worid\Hello worid.c(11) : error C2001: newline in constant
执行 cl.exe 时出错.

Hello worid.obj - 1 error(s), 0 warning(s)
额还是不对,难道我下的软件有问题
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-7-12 19:10:52 | 显示全部楼层    本楼为最佳答案   

少了个双引号:

  1. #include <stdio.h>
  2. #include <math.h>

  3. int main(void)
  4. {
  5.          double x, s;

  6.          printf("input number:\n");
  7.          scanf("%lf",&x);
  8.          s = sin(x);
  9.          printf("sine of %lf is %lf\n",x,s);
  10. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-7-12 19:17:16 | 显示全部楼层

感谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-7-13 15:24:55 | 显示全部楼层
一定要用#include <math.h>的预处理命令!!!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 13:20

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表