假设我必须逐行读取一个“ .txt”文件,该文件可以使我获得一堆最低的结果并将其存储为变量,以便随后进行打印(均以毫秒为单位的平均速度,通过“ velocidad_media”函数,以及提供这种结果时正在读取的文件的相应行):
int best_response = velocidad_media(fgets(ipresp, sizeof(ipresp), responses));
char best_ip;
responses = fopen("ips_responden.txt", "r");
while (fgets(ipresp, sizeof(ipresp), responses))
{
int response1 = velocidad_media(ipresp);
if (response1 < best_response) {
best_response = response1;
best_ip = response1;
}
printf("\n Velocidad de respuesta media: %d ms.\n", best_response);
printf(" IP seleccionada: %s", best_ip);
}
到目前为止,我已经能够存储这样的平均时间(如best_response)。但是我对“ best_ip”位感到困惑。我不知道如何初始化或将变量实现到我自己的代码中,以便也存储我实际正在读取的行并为我提供“ best_response”结果。请帮忙!