[C++] sh: pause: command not found 에러 해결

KIM SOO MIN·2023년 12월 11일

bugReport

목록 보기
9/12
📌 정말 간단한 문제였습니다.

패스트 캠퍼스에서 강의를 들으면서 system("pause") 라는 코드가 있었다.

C++에 무지한 나는 #include <stdio.h> header만으로 해당 코드가 작동할 줄 알았으나 아래의 에러를 발생시켰다.

sh: pause: command not found

stackoverflow에서 많은 답들이 #include <stdlib.h> 를 추가하면 된다는 답이 있었다.

하지만 #include <iostream> 을 추가해봐도 다른 것들을 추가해봐도 동일한 에러를 발생시켰다.

해결방법

Command system("pause") not found on Linux

드디어 찾았다.

system("pause");is meant to be used only on Windows. It runs the Windows command-line "pause" program and waits for that to terminate before it continues execution of your program. That's why it's a bad practice to use it in your code, no matter if you are running your code on Windows or Linux.

Windows나 Linux 기반에서 돌리지 않는 한 system("pause"); 는 Mac에서 돌아가지 않는다는 것이었다.

아직 #include 의 뜻이 무엇인지 몰라서 그럭저럭 해결했지만 공부하다보면 알 수 있겠지! —̳͟͞͞💁ᩚ

profile
3년차 풀스택 엔지니어입니다.

0개의 댓글