在Linux中,exit
是一个用于退出当前程序的命令
#include#include void my_function() { printf("This is my function.\n"); // 使用 exit() 函数退出程序 exit(0); } int main() { printf("This is the main function.\n"); // 调用 my_function() my_function(); // 如果在此处继续执行代码,将不会被执行 printf("This line will not be executed.\n"); return 0; }
在这个示例中,my_function()
会在执行到exit(0)
时立即终止程序。因此,main()
函数中的printf("This line will not be executed.")
将不会被执行。