输出:
sh: color: command not found
wa wa wash: pause: command not found
Program ended with exit code: 0
编辑器用的是xcode
system函数是可以用的,但是[划重点]
在Mac系统里system函数使用的是Terminal命令
所以,这个命令在Mac系统里不存在
通俗点说:你在程序里使用“system("cls")”就等于在Terminal中输入“cls”
但是在Terminal命令中没有color和wa命令,所以就会出现“command not found”[中文:命令未找到]错误,如果需要清屏,请使用“system("clear")”[这里说明一下,Mac清屏是很多个'\n']
附录:
外国的讨论(关于Mac system("pause"))
I haven't heard that Linux has this command. It should not. But there is no doubt that the system function can be used. If you don't mind changing from pressing any key to pressing the space bar, you can output "press the space bar to continue", and then use a while loop until getchar() returns the value "\n". If you use Windows system, you can use the getch() function in the conio.h library, so you can input without '\ n', but you can use the "system (" pause ")" function directly if you use Windows system.