C控件到达非void函数的末尾 #包括 #包括 int get_property_int(字符串提示); 内部主(空) { int i=获得适当的int(“高度:”); printf(“%i\n”,i); } int get_property_int(字符串提示) { int n; 做 { n=获取整数(“%s”,提示符); }而(n8),; { 对于(int j=0;j
不知道我做错了什么。C控件到达非void函数的末尾 #包括 #包括 int get_property_int(字符串提示); 内部主(空) { int i=获得适当的int(“高度:”); printf(“%i\n”,i); } int get_property_int(字符串提示) { int n; 做 { n=获取整数(“%s”,提示符); }而(n8),; { 对于(int j=0;j,c,cs50,C,Cs50,不知道我做错了什么。do。while循环在I返回n时工作在循环结束时…for循环本身也可以工作…您声明get\u PROPERT\u int以返回int类型的值,但函数中的任何位置都没有return语句 将其添加到函数末尾: #include <cs50.h> #include <stdio.h> int get_proper_int(string prompt); int main(void) { int i = get_proper_int("Height
do
。while
循环在I返回n时工作
在循环结束时…for循环本身也可以工作…您声明get\u PROPERT\u int
以返回int
类型的值,但函数中的任何位置都没有return
语句
将其添加到函数末尾:
#include <cs50.h>
#include <stdio.h>
int get_proper_int(string prompt);
int main(void)
{
int i = get_proper_int("Height:");
printf("%i\n",i);
}
int get_proper_int(string prompt)
{
int n;
do
{
n = get_int("%s",prompt);
} while (n<1||n>8);
{
for (int j = 0; j < n; j++)
{
printf("#\n");
}
}
}
int获取正确的int(字符串提示)
{
int n;
做
{
n=获取整数(“%s”,提示符);
}而(n8),;
{
对于(int j=0;j
您声明了get\u-property\u-int
以返回int
您的return
语句在哪里?
非常感谢。有没有办法不返回任何内容?@ToddChoi将返回类型设置为
void
int get_proper_int(string prompt)
{
int n;
do
{
n = get_int("%s",prompt);
} while (n<1||n>8);
{
for (int j = 0; j < n; j++)
{
printf("#\n");
}
}
return n;
}
int get_proper_int(string prompt)