using time.h to loop until reaching a user-specified time
hey all....this is a snippet of code which I am going to use to call a function called trace(), which traceroute's to a specified host. what I want to do here is traceroute continuously until a user-specified time.
this code is not returning the right times, and no matter what time I enter in, the program says it is roughly twice what the current time is and the difference is always 1024 seconds.
have I got the types right? there is probably something small I'm missing.
this will take some knowledge of <time.h> to solve.
#include<sys/time.h>
int option,
quit = 1,
temp1 = 0,
temp2 = 0;
double difference = 0;
time_t stoptime ;
time_t now;
struct tm stop;
now = time(NULL);
while(quit != 0)
{
printf("Please enter option.\n\n");
printf("1 Conduct a fixed number of Traceroutes.\n");
printf("2 Conduct Traceroutes Until a specific Time.\n");
printf("3 Quit\n\n\n");
scanf("%d", &option);
switch(option)
{
case 1 :printf("Please enter the time you would like to run Traceroute until.\n\n");