유닉스에서 파일을 압축하기위한 C 코드를 작성하려고했습니다. UNIX 셸 명령 "zip -r filepath"를 사용하여 시스템 기능을 사용하여 구현했습니다. zip -r filepath 명령은 UNIX 쉘을 통해 직접 실행할 때 작동합니다.UNIX 명령 줄을 통해 프로그래밍 방식으로 파일을 압축하는 방법은 무엇입니까?
나는
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
int system(const char *zip -r /root/Desktop/hi.txt);
return 0;
}
다음과 같이 코드를 위튼이 그러나 나는 말을 컴파일 타임 오류를 얻고있다
"error:expected ‘;’, ‘,’ or ‘)’ before string constant"
syntax system function : http://linux.die.net/man/3/system
int system(const char *command);
어떻게이 문제를 해결할 수 있습니까? UNIX 명령을 따옴표로 묶어 보았습니다. 작동하지는 않았지만.
system("zip -r /root/Desktop/hi.txt");
당신은 읽기 조금 더 많은 시간을 할애 할 필요가 좋은 C 책과 튜토리얼/예제 ... – Mat