为什么我定义的功能似乎无法运行

编程入门 行业动态 更新时间:2024-10-21 18:29:51
本文介绍了为什么我定义的功能似乎无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

运行时,我无法输入任何内容,并且程序只是结束并什么也不返回,尽管在我的代码中我想输入和输出某些内容.然后我尝试调试,在我定义的函数中设置了许多关键点,但直接转到代码的末尾.我定义的函数似乎无法运行.我对此感到困惑.你能告诉我出什么事了吗?先感谢您.

When run, I cannot input anything and the program just end and return nothing, though in my code I want to input and output something. And then I tried to debug, I set a lot of key points in the function that I defined, but it directly goes to the end of the code. It seems that the function I defined can't be run. I am confused about that. Could you tell me what was wrong? Thank you in advance.

#include<stdio.h> void day_of_year(); int main() { day_of_year; return 0; } void day_of_year() { int year; int month; int day; scanf_s("%d %d %d", &year, &month, &day); int day_tab[2][13] = { {0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31} }; int flag, j; flag = (year % 400 == 0) || ((year % 100 != 0) && (year % 4) == 0); for (j = 1; j < month; j++) day += day_tab[flag][j]; printf("%d", day); }

推荐答案

要调用该函数,您的语句应显示为day_of_year();,并带有括号.

To call the function, your statement should read day_of_year();, with the parentheses.

day_of_year;是不带括号的表达式,它评估函数的地址,然后对该函数不执行任何操作.

Without the parentheses, day_of_year; is an expression that evaluates the address of the function, then doesn't do anything with it.

更多推荐

为什么我定义的功能似乎无法运行

本文发布于:2023-11-17 02:00:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608392.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义   功能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!