소프트웨어개발

C 언어 cat 명령구현

보이드메인 2020. 12. 16. 19:09

C "cat" 명령을 구현해 보자.


bool catFile(const char* file, char* buf)

{

FILE* fp;

 

if ((fp = fopen(file, "r")) == NULL)

{

ERROR("%s file open fail\n", file);

return false;

}

if (fscanf(fp, "%s", buf))

fclose(fp);

return true;

}