Use fseek() to for random access to each line, but consider that it works well only when opening the file as binary (remove text \n translation).
In binary your file layout is as follows:
37107287533902102798797998220837590246510135740250\r\n
46376937677490009712648124896970078050417018260538\r\n
74324986199524741059474233309513058123726617309629\r\n
91942213363574161572522430563301811072406154908250\r\n
23067588207539346171171980310421047513778063246676\r\n
....
53503534226472524250874054075591789781264330331690\r\n
Means that each number starts at
(n-1)*52
Where
n is the line number the last two bytes are \r & \n.
If
d is the digit you want read on line
n then:
digit is at ((n-1)*52)+(50-1-d)
This sample shows as to access file:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *fp;
fp = fopen("BigNums.txt", "rb");
if (!fp)
{
printf("File not found!\n");
return -1;
}
for(;;)
{
char str[128];
char line[52];
printf("Insert number line [1-10]: ");
scanf ("%s", str);
int n = atoi(str);
if (n < 0)
break;
if (n<1 || n>100)
continue;
printf("Insert digit [1-50]: ");
scanf ("%s", str);
int digit = atoi(str);
if (digit<1 || digit>50)
continue;
fseek(fp, (n-1)*52, SEEK_SET);
fread(line, sizeof(line), 1, fp);
printf("Line [%50.50s] digit [%c], first 10 chars [%10.10s]\n", line, line[49-(digit-1)], line);
}
return 0;
}
I choosed to read a whole number each time and access single digits in memory using fread() because fseek() is an heavy function and is not a good idea to use it very often.
If you want read full lines sequentially you can use fgets(). Using it you cannot move back.
P.S. The sample miss checks on file and data format assuming that the file has the specified format and number of entries.