程序对比找差别问题,急急急!!
C/C++ code
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
main()
{
FILE *fptr1,*fptr2,*fptr3;
char temp[30],temp1[30],temp1add[30],temp2[30],temp2tel[30];
if ((fptr1=fopen("D:\\addr.txt","r"))==NULL)
{
printf("cannot open file");
exit ( 0 ) ;
}
if ((fptr2=fopen("D:\\tel.txt","r"))==NULL)
{
printf("cannot open file");
exit( 0 ) ;
}
if ((fpt…
我用以下部分程序执行时,为什么会出现这样的结果,请指教!!!
while(getc(fptr1)!=EOF )
{
fgets (temp1,30,fptr1 ) ;
fgets ( temp1add , 16 , fptr1 ) ;
fputs ( temp1 , fptr3 ) ;
fputs ( temp1add , fptr3 ) ;
while(getc(fptr2)!=EOF)
{
fgets ( temp2 ,30, fptr2 ) ;
if(strcmp(temp1,temp2)==0)
{
fgets ( temp2tel ,16 , fptr2) ;
fputs ( temp2tel , fptr3);
fputs("\n",fptr3);
}
}
rewind ( fptr2 ) ;
}
结果为iying
shanghai
2345
iming
chengde
4455
angpin
chongqing
9988
ejie
jianjing
0987
每个名字都少了一个开头的字母!!!!