You may want to use fscanf something like this.
Code:
#include <stdio.h>
int main(void)
{
static const char filename[] = "test.txt";
FILE *file = fopen(filename, "r");
if ( file != NULL )
{
int i, net, pins;
char name[14];
fscanf(file, "%*[^\n]%*c%*[^\n]%*c"); /* read and discard first 2 lines */
while ( fscanf(file, "%d\t%13[^\t]\t\t%d", &net, name, &pins) == 3 )
{
printf("net = %d, name = \"%s\", pins = %d:\n", net, name, pins);
for ( i = 0; i < pins; ++i )
{
int block, pin;
if ( fscanf(file, "\t(%d,%d)", &block, &pin) == 2 )
{
printf(" %2d - block = %d, pin = %d\n", i, block, pin);
}
}
}
fclose(file);
}
else
{
perror(filename);
}
return 0;
}
/* my output
net = 0, name = "i_63_", pins = 3:
0 - block = 0, pin = -1
1 - block = 180, pin = 0
2 - block = 226, pin = 0
net = 1, name = "i_50_", pins = 14:
0 - block = 1, pin = -1
1 - block = 218, pin = 0
2 - block = 245, pin = 0
3 - block = 253, pin = 0
4 - block = 266, pin = 0
5 - block = 287, pin = 0
6 - block = 291, pin = 0
7 - block = 302, pin = 1
*/
But you could also continue to use sscanf if you messed around with a %n to keep track of where you end up in the line of text.