 <pre> *Elset, elset = _121:0_125:0 1, </pre> <p>You can do this with something like:</p> <pre><code>char line[whatever_max]; int target[2000]; // track data set number to populate int target_pos = 0; while (fgets(line, whatever_max, fd)) { int lhs, rhs, total_chars_used, chars_used; if (sscanf(line, "*Elset, elset = _%d:%d%n", &amp;lhs, &amp;rhs, &amp;total_chars_used) == 2) { // somehow, record lhs:rhs as a target data set being loaded... target_pos = 0; target[target_pos++] = lhs; target[target_pos++] = rhs; while (sscanf(line + total_chars_used, "_%d:%d%n", &amp;lhs, %rhs, &amp;chars_used) == 2) { target[target_pos++] = lhs; target[target_pos++] = rhs; total_chars_used += chars_used; } } else if (sscanf(line, "%d,", &amp;data) == 1) // add data to all current targets... else assert(!"unparsable line"); } </code></pre> <p>Exact details depend on your data set storage structures.</p>