C语言getchar()什么情况下在scanf()后面写?

在scanf(%c, )中输入char类型数组的时候,有的情况需要加入getchar(),而有的情况却不用加入也可以正常运行,这是为什么呢?
这是是需要使用getchar()的代码
#include <stdio.h>
#include <stdlib.h>
int main()
{
    char* int_array;
    int no_els, i;
    printf("Enter the number of elements: ");
    scanf("%d", &no_els);
    getchar();                //修改
    int_array = (char*)malloc(no_els * sizeof(char));
    if (int_array == NULL)
        printf("Cannot allocate memory\n");
    else
    {
        for (i = 0; i < no_els; i++)
        {
            printf("Enter element %d: ", i + 1);
            scanf(" %c", int_array + i);   //修改
            getchar();        //修改
        }
        for (i = 0; i < no_els; i++)
            printf("Enter %d is %c\n", i + 1, *(int_array + i));
        free(int_array);
    }
    return 0;
}

但是,如果用循环的方式给一个字符数组赋值,循环语句scanf(“%c”, a[i]); 为什么又可以实现字符的输入呢(不需要getchar()函数接收回车字符)
for(i=0;i<10; i++)
{scanf(“%c, a[i]);}

在给数组赋值时,需要使用getchar()函数来吸收回车键。那么上面这个循环同样是给数组赋值,为什么又可以不使用getchar()来接收回车键?
求解答!

scanf根据你限制的输入类型提取 getchar字符都接收 如果把scanf换成getchar 或 gets() 这时就需要 getchar吃掉无用回车