답안 #14064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14064 2015-04-26T05:13:37 Z sleep4725 이상한 수열 (OJUZ10_bizarre) C
컴파일 오류
0 ms 0 KB
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	int a;
	scanf("%d", &a);
	int* arr = NULL;
	int m;
	int i;
	int sum = 0;
	arr = (int*)malloc(sizeof(int)* a);
	
	for (i = 0; i < a; i++)
	{
		scanf_s("%d", &arr[i]);
	}
	sum = arr[a - 1];
	scanf_s("%d", &m);
	for (i = a-1; i < m-1; i++)
	{
		sum = sum+1;
	}
	printf("%d", sum);
	return 0;
}

Compilation message

bizarre.c: In function ‘main’:
bizarre.c:16:3: warning: implicit declaration of function ‘scanf_s’ [-Wimplicit-function-declaration]
   scanf_s("%d", &arr[i]);
   ^
bizarre.c:7:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &a);
  ^
/tmp/ccULkFwD.o: In function `main':
bizarre.c:(.text.startup+0x4b): undefined reference to `scanf_s'
bizarre.c:(.text.startup+0x71): undefined reference to `scanf_s'
collect2: error: ld returned 1 exit status