我是一名初学者编程学生。
在这里,我使用C++在Xcode中编写了一个简单的“两个数字之和”程序。
//preprocessor directive
#include <stdio.h>
//local declarations
int main (void)
{
//declare variables
int n1, n2, sum;
//input prompts
printf("This program finds the sum of two numbers. Enter your first number.\n");
scanf("%d" , &n1);
printf("Enter another number.\n");
scanf("%d" , &n2);
//process
sum=n1+n2;
//output
printf("The sum is %d." , sum);
return 0;
}
据我所知,我的语法是正确的,但是当我尝试构建程序时,出现了以下错误代码:
"Apple Mach-O Linker (Id) Error. Linker command failed with exit code 1 (use -v to see invocation)"
我已经阅读了其他问题和答案,但无法解决此问题。是否有任何解决方案?非常感谢!