- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我实际上按照我用来学习 C 的教科书中的方式编写了这段代码。我不确定这些错误意味着什么或从哪里开始。请帮忙。我正在使用 Xcode。
// Specific Age Calculator
//
// Created by Christopher Pettit on 10/11/17.
// Copyright © 2017 Christopher Pettit. All rights reserved.
#include <stdio.h>
#define TARGET_AGE 88
int year1, year2;
int calcYear(int year1);
int main(void)
{
// Ask the user for their birth year
printf("What year were you born?\n");
printf("Enter as a 4-digit year (YYYY) " );
scanf(" %d", &year1);
// Calculate the future year and display it
year2 = calcYear(year1);
printf("Since you were born in %d, you will be %d in %d. ",
year1,TARGET_AGE,year2);
return 0;
// This function to get the future year
int calcYear (int year1);
{
return (year1+TARGET_AGE);
}
}
最佳答案
花括号放错了位置。因此,函数 calcYear
未定义,因为它隐藏在 main
中。
在不解释程序含义的情况下,只是为了修复链接器错误,该错误表示没有 calcYear
的定义,代码可能如下所示:
return 0;
} // this one inserted
// This function to get the future year
int calcYear (int year1) // ; this semicolon was deleted
{
return (year1+TARGET_AGE);
}
//} this one deleted
关于c - 我在一本使用 Xcode 的教科书中发现运行 C 程序时出错。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46697504/
这个问题在这里已经有了答案: Convert int to double (3 个答案) 关闭 4 年前。 我正在根据课文学习 C。作者提供的示例代码是: #include main() { in
我正在为一个学校项目实现 RSA 密码系统。我在 Linux 上用 C 语言做这个项目,我使用 GNU MP 库进行大部分数学运算。 出于某种原因,对于具有相同消息的不同公钥,我总是得到相同的密文,所
int x = random(); int y = random(); unsigned ux = (unsigned) x; unsigned uy = (unsigned) y; 对于以下每个 C
int x = random(); int y = random(); unsigned ux = (unsigned) x; unsigned uy = (unsigned) y; 对于以下每个 C
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
我是一名优秀的程序员,十分优秀!