-------用break,表示跳出当前循环。 for(k=0;k<CNUM;k++) { if( 0 == memcmp(cnty[k].CntName ,addr,4) ) { cnty[k].Num++; break; //加上这句 } }