compilando o meu ep com as flags "-Wall -pedantic -ansi -O2" tenho o seguinte warning:
"ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]"
Para eliminar o warning devido o scanf
ou fscanf
basta compilar com a opção -Wno-unused-result
. Assim, as opções de compilação passam a ser:
-Wall -O2 -pedantic -ansi -Wno-unused-result
A propósito, vejam logo a seguir o que a man page do scanf diz. Os avisos são devidos ao fato de ignorarmos os valores retornados pela função:
meu_prompt> man scanf
SCANF(3) Linux Programmer's Manual SCANF(3)
NAME
scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf - input format conversion
SYNOPSIS
#include <stdio.h>
int scanf(const char *format, ...);
int fscanf(FILE *stream, const char *format, ...);
int sscanf(const char *str, const char *format, ...);
#include <stdarg.h>
int vscanf(const char *format, va_list ap);
int vsscanf(const char *str, const char *format, va_list ap);
int vfscanf(FILE *stream, const char *format, va_list ap);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
vscanf(), vsscanf(), vfscanf():
_XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
DESCRIPTION
The scanf() family of functions scans input according to format as described below. This
format may contain conversion specifications; the results from such conversions, if any,
are stored in the locations pointed to by the pointer arguments that follow format. Each
pointer argument must be of a type that is appropriate for the value returned by the cor‐
responding conversion specification.
[... monte de informações removidas ...]
RETURN VALUE
These functions return the number of input items successfully matched and assigned, which
can be fewer than provided for, or even zero in the event of an early matching failure.
The value EOF is returned if the end of input is reached before either the first success‐
ful conversion or a matching failure occurs. EOF is also returned if a read error occurs,
in which case the error indicator for the stream (see ferror(3)) is set, and errno is set
indicate the error.
[... mais monte de informações removidas ...]