I've already gotten my code to obtain the best option (lower integer as time of response) out of different IP's stored in a .txt file, line after the other with line breaks between them. Now, I've to do the same off a redirected .txt file with different DNS servers surrounded by strings of text. I just need going through the file and taking the average time of response in order to compare recursively and print the winner. That's my previous code, made for a "line after line" approach, without need to browse through character strings:


Code:
int best_response = 0;
char best_ip[sizeof(ipresp)] = "";
int best_valid = 0;
responses = fopen("ips_responden.txt", "r");
if (responses != NULL)
{
    while (fgets(ipresp, sizeof(ipresp), responses))
    {
        int response1 = velocidad_media(ipresp);
        if (!best_valid || response1 < best_response) {
            best_response = response1;
            strcpy(best_ip, ipresp);
            best_valid = 1;
        }
    }
    printf("\n\n    Average time: %d ms.\n", best_response);
    printf("    Best IP: %s", best_ip);
}
My redirected .txt file would look like this:


Code:
Configuraci˘n para la interfaz "Ethernet" 
Servidores DNS configurados a trav‚s de DHCP: 80.10.11.220 
80.11.43.220 
Registrar con el sufijo: Solo el principal

And I'd need to go through the DNS servers only, like the aforementioned code but being able to filter. What I'm working on is this following piece of code:


Code:
char term = "DNS", line[500];
char target = ":", result[100];

FILE* dns = fopen("dns.txt", "r");
    while (fgets(line, sizeof line, dns)) {
        if (strstr(line, term)) {
            strchr(result, target);
        }
            strcpy(result);
        }
    printf("String copied: %s", result);
    }
fclose(dns);
Still not working. My idea would be put the pointer to a line where "DNS" was to be found and start reading from the ":" on. But I'm not sure about how to extract the whole DNS server (maybe taking into consideration that it's always following the XX.XX.XX.XXX format would be helpful) and iterate through the file in order to implement the extraction to the code block I've pasted before.