methodtest.c:(.text+0x47): 对 `pritnf' 的未定义引用
所以我第一次尝试在 c 中使用方法,当我编译时,我得到这个作为输出,
gcc -o methodtest methodtest.o
methodtest.o: In function `main':
methodtest.c:(.text+0x47): undefined reference to `pritnf'
collect2: ld returned 1 exit status
make: *** [methodtest] Error 1
代码看起来像这样,
void main(void)
{
int num, num2, num3;
num = 3;
num2 = 2;
num3 = 1;
int ans = addem(num, num2, num3);
pritnf("%d\n", ans);
}
int addem(int num, int num2, int num3)
{
return(num+num2+num3);
}
为什么我会收到这个错误或其他错误?
So im trying to work with methods for the first time in c and when i compile i get this as an output
gcc -o methodtest methodtest.o
methodtest.o: In function `main':
methodtest.c:(.text+0x47): undefined reference to `pritnf'
collect2: ld returned 1 exit status
make: *** [methodtest] Error 1
the code looks like this
void main(void)
{
int num, num2, num3;
num = 3;
num2 = 2;
num3 = 1;
int ans = addem(num, num2, num3);
pritnf("%d\n", ans);
}
int addem(int num, int num2, int num3)
{
return(num+num2+num3);
}
why why am i getting this error or whatever it is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来像一个拼写错误:
pritnf
应该是printf
Looks like a typo:
pritnf
should beprintf
除了 printf 拼写错误之外,您不能像这样在 main 中间分配变量。在 C 中,所有变量都必须分配在作用域的开头(直接在“{”之后)。
也许您已将编译器设置为将代码编译为 C++?
Apart from the printf typo, you can't allocate variables in the middle of main like that. In C, all variables must be allocated at the beginning of the scope (directly after the "{" ).
Though perhaps you have set the compiler to compile the code as C++?