串口设置问题


void set_serial_speed(int fd,int speed)
{
speed_t SpeedArr[] = {B115200,B57600,B38400,B19200,
B9600,B4800,B2400,B1200,B300};
int NameArr[] = {115200,57600,38400,19200,
9600,4800,2400,1200,300};
int i;
int Statue;
struct termios Opt;

tcgetattr(fd,&Opt);

for(i=0; i<sizeof(SpeedArr)/sizeof(int); i++)/条件的含义?/
{
if(speed == NameArr_)
{
tcflush(fd,TCIOFLUSH);
cfsetispeed(&Opt,SpeedArr);
cfsetospeed(&Opt,SpeedArr);
Statue = tcsetattr(fd,TCSANOW,&Opt);
if(Statue != 0)
{
return;
}
tcflush(fd,TCIOFLUSH);
}
}
}

条件语句中的i<sizeof(SpeedArr)/sizeof(int)是什么意思,为什么要拿数组的大小和int的大小做比较?_

用来求出数组里元素的个数…