首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Scanf在%4&调用对象中仅输入%1值不是函数或函数指针错误

Scanf在%4&调用对象中仅输入%1值不是函数或函数指针错误
EN

Stack Overflow用户
提问于 2021-11-14 15:30:40
回答 1查看 20关注 0票数 0

所以我试着把一个计算三角形高度的程序放在这里:

代码语言:javascript
复制
#include <stdio.h>

void main()
{
     float shorty_to_lefty=0.0f , lofty_to_tree=0.0f, lofty=0.0f , shorty=0.0f , arbre=0.0f;

     printf("\nRentrer la distance entre le petit et le grand:" );
     scanf("%0.2f", &shorty_to_lefty);
     printf("\nRentrer la distance entre le grand et l'arbre:" );
     scanf("%0.2f", &lofty_to_tree);
     printf("\nRentrer la taille du petit" );
     scanf("%0.2f", &shorty);
     printf("\nRentrer la taille du grand:" );
     scanf("%0.2f", &lofty);
     
    arbre= lofty+(shorty_to_lefty/lofty_to_tree)(lofty-shorty)/shorty_to_lefty;

    printf("La taille de l'arbre est de %.2f m", arbre);
    


}

但问题是,当我启动它时,scanf只输入1个值,而不是其余的ex: Rentrer la distance entre le petit et le grand:

代码语言:javascript
复制
2

Rentrer la distance entre le grand et l'arbre:
Rentrer la taille du petit
Rentrer la taille du grand:La taille de l'arbre est de -1.#J m

在最后一个浮点arbre= lofty+(shorty_to_lefty/lofty_to_tree)(lofty-shorty)/shorty_to_lefty中,当我试图编译时,我得到了这个错误

代码语言:javascript
复制
Arbre.c: In function 'main':
Arbre.c:16:34: error: called object is not a function or function pointer
     arbre= lofty+(shorty_to_lefty/lofty_to_tree)(lofty-shorty)/shorty_to_lefty;

((shorty_to_lefty/lofty_to_tree)下有一个箭头)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-14 15:47:26

问题1:

%f替换%0.2fscanf格式说明符与printf的格式说明符相似,但不完全相同。

问题2:

代码语言:javascript
复制
...lofty_to_tree) (lofty - shorty) ...
                 ^
                 an operator is misssing here, possibly *
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69964479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档