打印功能,C语言中的helloworld
几天前开始阅读 C,我正在尝试学习如何将我的代码拆分为函数,谁能告诉我为什么它不为我打印“hello world”?
#include <stdio.h>
void PRINT(){
printf("hello world");
}
int main() {
void PRINT();
}
回答
你应该像这样调用函数:
int main() {
PRINT();
}
- Yup — the `void PRINT();` in `main()` is a stray, unnecessary, non-prototype declaration of `PRINT()`, not a call to it.
回答
尝试这个:
int main()
{
printf("Hello World");
return 0;
}
或者试试这个:
void PRINT(){
printf("Hello World");
}
int main() {
PRINT();
}
- The `return 0;` has been optional since C99 was defined.