For %c
conversion specifier, scanf does not omit whitespaces as it does for %d
for example. You have to tell scanf to skip whitespaces and then read first non-whitespace character. Here's your fixed code.
#include<stdio.h>
#include <stdlib.h>
int main()
{
int i,l,*A;char C;
A=malloc(5*sizeof(int));
for(i=0;i<5;i++)
scanf("%d",A+i);
scanf(" %c",&C);
// ^ here
scanf("%d",&l);
printf("%d%c\n",l,C);
free(A); // remember to free what you've malloc'd
return 0;
}
Since you are asking how to verify return value from scanf, see prototype of scanf:
int scanf(const char *format, ...);
As you can see, it returns int. Man page says even more about return value:
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.
This part I will leave for you to do it. I hope that it is now clear how to check scanf's return value.