#include #include extern int atoi(); int random_number(); int rand_time(); static int w=184; void main(argc, argv) int argc; char *argv[]; { char c; int r; FILE *fp,*fopen(); if (argc>1) if(argc<3) { printf("USAGE: Quotes <# of quotes>\n"); exit(0); } else { fp=fopen(argv[1],"r"); w=atoi(argv[2]); } else fp=fopen("s:quotes.txt","r"); if (fp==NULL) { printf("File error!\n"); fclose(fp); exit(0); } r=random_number(); while (r>0) { c=getc(fp); if (c=='\t') r--; } c='\n'; while(c!='\t') { c=getc(fp); printf("%c",c); } printf("\n\n"); fclose(fp); } int random_number() { int y=0,i=1,x=99; y=rand_time(); while (x!=0) { if (y==5 || y==0) { x=0; } else { y=rand_time(); i=i+1; if(i==w) { i=1; } } } return(i); } /* Le Random de funtion */ int rand_time() { struct tm *tp; long t; char *timing; int y; time(&t); tp=localtime(&t); timing=asctime(tp); y=timing[18]; y=y-48; return(y); }