编译出错,不知道为什么
#include <stdlib.h> #include <stdio.h>
#include <time.h>
void main( void )
{
printf("********************************\n");
printf(" Welcome to use PYB \n");
printf("********************************\n");
/*抗心绞痛药的随机遴选*/
char c1[7][70]={"1 硝酸异山梨酯","2 曲美他嗪","3 硝酸甘油","4 硝酸异山梨酯","5 硝苯地平","6 地尔硫","7 卡维地洛"};
int i,k;
srand( (unsigned)time( NULL ) ); /*设置随机数种子*/
printf("一、抗心绞痛药:\n");
for( i=0; i<7;i++ )
{
k=rand()%2; /*产生随机数1或0*/
if(k==1) /*当随机数等于1时打印出药名*/
printf("%s\n",c1[i]);
}
printf("\n");
} 错误:C:\Documents and Settings\Administrator\桌面\pyb.c(12) : error C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\Administrator\桌面\pyb.c(13) : error C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\Administrator\桌面\pyb.c(16) : error C2065: 'i' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\pyb.c(18) : error C2065: 'k' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\pyb.c(20) : error C2065: 'c1' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\pyb.c(20) : error C2109: subscript requires array or pointer type