我正在编写一个函数Calculate_age_when_Trump_elected(int year_born)
来返回结果,并为age_when_Trump_elected
分配一个值。
结果应该是YEAR_TRUMP_ELECTED
减去特朗普诞生的年份,但目前只显示用户输入的输入。
“terminal_user_input.c”只是函数read_string
和read_integer
的文件。
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#include "terminal_user_input.c"
#define YEAR_TRUMP_ELECTED 2016
// A very basic read boolean function
bool read_boolean(const char* prompt)
{
my_string answer;
bool result;
answer = read_string(prompt);
answer.str[0] = (char) tolower(answer.str[0]);
switch (answer.str[0]) {
case 'n':
result = false;
break;
case 'x':
result = false;
break;
default:
result = true;
}
return result;
}
int Calculate_age_when_Trump_elected(int year_born)
{
int result;
result = YEAR_TRUMP_ELECTED - year_born;
return 0;
}
int main()
{
my_string name;
int age_when_Trump_elected;
int year_born;
bool brexiter;
name = read_string("What is your name? ");
year_born = read_integer("When you were born? ");
age_when_Trump_elected = Calculate_age_when_Trump_elected(year_born);
printf("You were %d years old when Trump was elected\n",year_born);
brexiter = read_boolean("Are u a Brexit support? ");
if (brexiter == true)
{
printf("%s is a Brexit supporter\n",name.str);
}
else
{
printf("%s isn't a Brexit supporter\n",name.str);
}
read_string("Type 'exit' to continue ");
return 0;
}
答案 0 :(得分:1)
看看0
。它将始终返回result
。您应该返回<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout>
<android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar/>
</android.support.design.widget.AppBarLayout>
<LinearLayout>
<include layout="@layout/drawer_header"/>
<android.support.design.widget.NavigationView/>
<include layout="@layout/drawer_footer"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
变量。