Ha, finally I've gone through it - seems like numbers also worked with that, and the value of my variable was used as well.
I'm finally done with this project. Thanks A LOT anyone who provided help...
Type: Posts; User: JSteel
Ha, finally I've gone through it - seems like numbers also worked with that, and the value of my variable was used as well.
I'm finally done with this project. Thanks A LOT anyone who provided help...
Now, and this is the final part of my project: once I've got the best response for both my IP's and DNS servers, I must compare them and, if IP shows a faster time of response, replace the DNS server...
Got it on my own! My extraction of DNS servers lacked a fclose at the end of it. :wink: I was close to insanity...
Double posted and asked some further nonsense, haha. Sorry for the hassle.
Now, after having spent my time modularizing the whole program, my main looks like this:
int main()
{
FILE*...
Update: I've tried out, through a different file and folder (where I've copied the same dns_responden.txt file) the following code, in order to follow laserlight's signature hint. Compiles and works...
Hey laserlight! Thanks for your input. True about the names but, as with the rest of the code, I just wanted to transpose the previous block with slightly different nomenclature in order to avoid...
Yes, sorry. I've tried to simplify working in different modules now.
First one should export to dns_responden.txt those DNS servers. Working fine so far:
void extraerDNS() {
FILE*...
Now, almost there...
Trying to pick the DNS server that coincides with the lower average time value. This worked well with my IP block:
int best_response = 0;
char...
Got it!
printf("Average time of response: %s ms.\n", dns_s1);
How foolish of me printing an int with %s!:)
Works as a charm, mate! Thanks again!
Now I'm in a different problem:
printf("\n\DNS: %s\n", ip_str);
int dns_s1 = velocidad_media(ip_str);
...
Thanks a lot for your response again. Didn't compile well so I just added some ending commas and initialized the variables a, b, c and d. Don't know if I did it well, since it crashes when...
Hey John, thanks a lot once again for your response.
Many concepts escaping my understanding there, so it's a bit of copying/pasting blindly this time. I guess I just need to modify that "input.txt"...
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...
Still trying to solve my loop but I feel I'm close to it.
int best_response = velocidad_media(fgets(ipresp, sizeof(ipresp), responses));
char best_ip;
responses =...
Still stuck in a loop. :D
I've asked my teacher and he gave me some guidelines, including a new line which includes a new variable, namely response2 here, but still unable to fix this part....
I've finally come across the solution by myself, due to an annoying \n out there. As for temporary files, no worries, I'll do well with normal redirection.
Now, that I'm almost there, I need one...
Ha, the tmp conversion is troublesome, indeed. I'm following this route:
FILE* tmp = tmpfile();
while (fgets(ch, sizeof(ch), fp))
{
printf("Lanzando ping a %s", ch);
...
Thanks a lot once again, Salem. Worked perfectly. Now my code looks like this:
fp = fopen(x, "r");
FILE* responses = fopen("ips_responden.txt", "w"); // FILE* tmp = tmpfile();
...
Guess who's back...;)
I need a slight modification of this piece for a different program.
Instead of printing "The IP responds...", I should redirect the IP whose ping has shown success in...
Sorry for the annoyance, but after some time of struggle I think I'm almost there and it's annoying indeed not finding how...
So now I have:
#define _CRT_SECURE_NO_WARNINGS
#include...
Ha, sorry for my insistence. I've reworked my code, implementing john.c's instead of that of the previous post (which proved to be a bit problematic). So far:
#define _CRT_SECURE_NO_WARNINGS...
I'm back, sir. ;)
Now that I've got the other two modules straight, I'm having some more hard time for a switch menu that allows me selecting among my different network adapters and, once selected,...
Yeah, sure. That was easy indeed, I might be too fed up with all this homework to even function properly, and I'm taking note of the quote thing as well. Cheers and, once again, thanks for your...
Man, that works wonderfully. I've finally implemented the latter to my code and modified quite some things but works excellently. Only one more thing: would it be possible to store those numbers as...
Oh, yes, my bad.
That output file I'm scanning would look like:
I would need to extract the last number in the last line after the "Media = " substring, minus the "ms" unit. In this case, the...