System call write()을 이용한 C프로그램 작성 질문입니다.
프로그램 작성하다가 막혀서 글올립니다.
두개의 string 입력값을 파일 실행시 받아서
예) program abc def
이 두개의 스트링을 합쳐서 새로운 스트링을 만들어서
이걸 write system call 을 사용해서 standard output으로
출력(output)하는 프로그램을 작성하는 건데요
include는 뭘 쓸지 걱정안해도 되는대신 입력값 숫자는 체크를 해줘야 한다네요.
제가 작성한건
#define BUFFSIZE 1024
int main(int argc, char *argv[]) {
char *str;
int i = 0;
if (argc != 3) {
printf("Error: Enter the right parameter");
exit(-1);
}
여기까지 입니다.
write()이란 함수를 한번도 다뤄보지 못해서
저 다음부터 어떻게 작성해야할지 감이 안오네요.
프로그램이 요구하는건
->program abc def
->abcdef
뭐 이런식인거 같은데..
Write a C program for UNIX which takes two strings as command line parameters, create a new string as their concatenation and outputs the concatenation to standard output using the 'wirte' system call. You do not need to worry about the 'includes' but you should check the number of parameters.
이게 전문이고요, outputs the concatenation to standard output using the 'wirte' system call 이부분이 이해가 안되네요..
홀로 유학생활 하는데 물어볼 사람 하나 없고 정말 ㅠ 답답해서 여기다 글올립니다.
도움 주시면 정말 감사하겠습니다!
자세한 건 write 함수의 매뉴얼을 보시고...
자세한 건 write 함수의 매뉴얼을 보시고...
* 표준출력에 해당하는 fd 값은 1입니다.
* buf 에는 새로 만든 스트링(명령행 인자로 받은 두 스트링을 합친 거)의 시작 주소,
* count 에는 새로 만든 스트링의 길이를 넣으시면 되겠네요.
* 두 스트링을 합치는 방법이 필요하시다면 strcat 함수를 살펴보세요.
좋은 하루 되세요!
댓글 달기