It took me alot of time but here it is :)
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
FILE *file;
file=fopen("Options.txt", "rb");
int newlines=0;
int c,l;
int a;
char f;
int n=0;
char ch;
int line;
if(file==NULL){
return 1;
}
printf("\t\tWelcome to the magic 8ball, Coded by +=[Moudi]=+ \n\n");
printf("Ask any question you desire ! ( Yes or no question )\n");
scanf("%d", &l);
printf("\n\n");
while ((c=fgetc(file))!=EOF) {
if (c=='\n') {
newlines++;
}
}
if(newlines!=0){
newlines=newlines+1;
}
srand(time(NULL));
line = rand() % newlines;
n = 0;
rewind(file);
while ( (ch = fgetc(file)) != EOF )
{
if ( n == line )
{
putchar(ch);
}
if ( ch == '\n' )
{
++n;
}
}
printf("\n\n");
system("Pause");
fclose(file);
}
Comments :D?