I want to read below lines in input.txt file in C program and assign it to variables.
(1,3) (4,8)
(3,6) (3,10)
(2,6) (4,56)
...it has to read more than 100 lines and draw lines with 4 values in each line.
I was using fgets and sscanf, but I am not able to get the value and below was my code.
static const char filename[] = "src/input.txt";
FILE *file = fopen ( filename, "r" );
if ( file != NULL )
{
char line [ 128 ];
int i,j,k,l=-1;
while ( fgets ( line, sizeof line, file ) != NULL )
{
fputs ( line, stdout ); /* write a line */
sscanf (line,"%d" "%d" "%d" "%d", i,j, k,l);
}
fclose ( file );
}