后面乱码出现的原因是什么? 什么情况下还会出现这种类似的乱码??

后面乱码出现的原因是什么? 什么情况下还会出现这种类似的乱码??

#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(int score[],int m, int below[])
{
    int i,sum=0,count=0,j,k=0;
    float av=0.0;
    for(i=0;i<m;i++)
    {
        sum+=score[i];
        count++;
    }
    av=sum/m;
    for(j=0;j<m;j++)
    {
        if(score[j]<av)
        {
            below[k++]=score[j];
        }
    }
    return count;

}
void main()
{
  FILE *wf;
  int i, n, below[9];
  int score[9]={10,20,30,40,50,60,70,80,90};
  system("CLS");
  n=fun(score, 9, below);
  printf("\nBelow the average score are: ");
  for(i=0;i<n;i++)  
     printf("%d ",below[i]);
/******************************/
  wf=fopen("out.dat","w");
  for(i=0;i<n;i++)  
     fprintf(wf,"%d ",below[i]);
  fclose(wf);
/*****************************/
}

```![图片说明](https://img-ask.csdn.net/upload/201909/07/1567833092_247668.png)
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int fun(int score[],int m, int below[])
{
    int i,sum=0,count=0,j,k=0;
    float av=0.0;
    for(i=0;i<m;i++)
    {
        sum+=score[i];
        count++;
    }
    av=(float)sum/m;
    for(j=0;j<m;j++)
    {
        if(score[j]<av)
        {
            below[k++]=score[j];
        }
    }
    return count;

}
void main()
{
  FILE *wf;
  int i, n, below[9]={};
  int score[9]={10,20,30,40,50,60,70,80,90};
  system("CLS");
  n=fun(score, 9, below);
  printf("\nBelow the average score are: ");
  for(i=0;i<n;i++)
     printf("%d ",below[i]);
/******************************/
  wf=fopen("out.dat","w");
  if(wf)
  {
      for(i=0;i<n;i++)
          fprintf(wf,"%d ",below[i]);
      fclose(wf);
  }
/*****************************/
}