void bar()
表示 bar
不返回任何值。我很好奇,如果 void
不返回任何值,那么为什么编译器(GCC)在编译以下程序时没有给出任何警告或错误?
#include <stdio.h>
void foo (void)
{
printf("In foo() function\n");
}
void bar (void)
{
printf("In bar() function\n");
return foo(); // Note this return statement.
}
int main (void)
{
bar();
return 0;
}
我使用
gcc -Wall myprog.c
进行编译,程序可以正常运行。
return
来中断函数。 - Havenard