| 
 
일단 함수내 명시 선언한 함수의 prototype과 실제 호출문의 파라메터가 다릅니다. 굳이 malloc()
 함수를 명시 선언 하시고 싶으시다면  
 
 :     char *malloc();
 
 요 문장을
 
                 void* malloc(size_t size);
 
 등으로 표시하시면 해결될 듯 합니다. 물론 그 라인 자체를 삭제하셔도 무방합니다. 
 
 이 외에도 한가지 더 말씀 드릴 것은, malloc()함수의 리턴
 타입은 void*이고, 그 리턴값이 assign되는 변수 ps[]는 char* 라는 점입니다. 아마도 implicit
 type converting 경고 정도가 나오지 않을까 합니다. (컴파일러가 없어서 확인은 못드리겠군요.)
 따라서 다음 문장도 고쳐주시는 것이 좋겠습니다. 
 
 :         if((ps[index] = malloc (strlen(temp)+1))==NULL)  
 이 문장을
 
          if((ps[index] = (char*)malloc (strlen(temp)+1))==NULL)  
 
 이렇게 고치는 것을 추천드립니다. 마지막으로 한가지만 더 말씀드리면 ps[]가 free되지 않고
 프로그램이 끝나는군요. 그 부분도 추가하시면 금상첨화겠습니다. 
 
 
 
 
 Rainsinger.
 
 
 
 한성현 님이 쓰신 글 :
 : #include <stdio.h>
 : #include <string.h>
 : #include <stdlib.h>
 : 
 : #define LINE 81
 : #define MAX 100
 : 
 : void main()
 : {
 :     char temp[LINE];
 :     char *ps[MAX];
 :     int index=0;
 :     int count;
 :     char *malloc();
 : 
 :     puts("Name some anything.");
 :     puts("Enter them ont at a time; [enter] at the start");
 :     puts("of a line to end your list. Okay, I'm ready.");
 : 
 :     while(index<MAX && gets(temp)!=0 && temp[0]!='\0')
 :     {
 :         if((ps[index] = malloc (strlen(temp)+1))==NULL)  // Extra parameter in call to malloc()
 :         {
 :             printf("Out of Memory \n");
 :             exit(0);
 :                 }
 :         strcpy(ps[index],temp);
 :         if(++index<MAX)
 :             printf("That's %d, Continue.\n",index);
 :     }
 : 
 :     puts("Okay, here is what I've got.");
 :     for(count=0; count<index;count++)
 :         puts(ps[count]);
 : }
 : 
 : 이상하게도 malloc()함수만 들어가면 Extra parameter call 에러가 납니다.
 : 터보씨 3.1윈도우용 버전이고 윈도우 xp 입니다..
 : 
 : ps[index]=malloc(strlen(temp)+1);
 : 
 : 이문장이 잘못된건가여??
 : 가르침 부탁드립니다~~
 
    |