답안 #14899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14899 2015-07-05T13:43:27 Z cepiloth 줄 세우기 (KOI13_jul) C++
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TRUE 1
#define FALSE 0

typedef char BOOL;

BOOL getUserMessage(char* arg)
{
  	char szTemp[256];
	printf("input first change \r\n");  
  	scanf("%c", szTemp);
  
  	arg = (char*)malloc(sizeof(char) * strlen(szTemp));
  	strcpy(arg, szTemp, strlen(szTemp));
  
  	return TRUE;
}

int main()
{
  BOOL nRet = TRUE;
  nRet = getUserMessage();
  if(nRet == FALSE)
    printf("invalid message exit() \r\n");
  
  return TRUE;
}

Compilation message

jul.cpp: In function ‘BOOL getUserMessage(char*)’:
jul.cpp:17:38: error: too many arguments to function ‘char* strcpy(char*, const char*)’
    strcpy(arg, szTemp, strlen(szTemp));
                                      ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from jul.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string3.h:102:1: note: declared here
 __NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
 ^
jul.cpp: In function ‘int main()’:
jul.cpp:25:25: error: too few arguments to function ‘BOOL getUserMessage(char*)’
   nRet = getUserMessage();
                         ^
jul.cpp:10:6: note: declared here
 BOOL getUserMessage(char* arg)
      ^
jul.cpp: In function ‘BOOL getUserMessage(char*)’:
jul.cpp:14:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%c", szTemp);
                       ^