win10系统,使用命令行gcc 和使用cfree 编译生成的.exe运行结果不同


#include <stdio.h>
#include <stdlib.h>

#define SIZE 8

void itob(int inp,char *numbin);
int main(void)
{
    int inp1,site,outcome;
    char numbin[SIZE];

    puts("Please enter an integer.");
    fscanf(stdin,"%d",&inp1);      //传入待处理的数
   
    puts("Please enter the number of site.");
    fscanf(stdin,"%d",&site);      //传入待处理数的二进制第几位

    itob(inp1,numbin);     //将待处理数转为二进制,保存至数组
    printf("%d\n",site);     //显示待处理数的二进制第几位
    printf("The binary number is %s\n",numbin);
    fprintf(stdout,"The %d site is %c\n",site,numbin[site - 1]);
    system("pause");

    return 0;
}

void itob(int inp,char *numbin)  //十进制转二进制,字符数组保存
{
    int i = SIZE - 2;

    while(inp)
    {
        numbin[i] = (1 & inp) + '0';
        i--;
        inp >>= 1;
    }
    numbin[SIZE] = '\0';

    while(i >= 0)
        numbin[i--] = '0';
}

键盘输入数字32 ,位数2
使用命令行gcc编译后的a.exe,结果:
Please enter an integer.
32
Please enter the number of site.
2
0
The binary number is 0100000
The 0 site is
请按任意键继续
使用cfree编译后的结果:
Please enter an integer.
32
Please enter the number of site.
2
2
The binary number is 01000000
The 2 site is 1

gcc编译的里面,不知道为什么itob函数会改变传入的site的值,但是并没有把site的地址传进去,求各位解答

在每个最后不带\n的printf后面加fflush(stdout);
在每个不想受接收缓冲区旧内容影响的scanf前面加rewind(stdin);
另外请检查scanf的返回值。