Lab 2 Task 1.1 confusion

Beiträge: 29
Registriert: 23. Okt 2014 15:33

Lab 2 Task 1.1 confusion

Beitrag von pranay » 27. Nov 2015 03:25

It is written that:
Use the following formatting: "current time: %llu seconds\n"
(%llu is the correct format code for printing unsigned long long values).
Does it mean we only have to show sedond part of current time? Or do we have to convert current time into seconds?
For example, Current time is 3:23:27Hrs.
So, do we need to show 23 Sec
OR (3600*3)+(23*60)+27 = 12203 Sec ??

Beiträge: 8
Registriert: 3. Dez 2014 13:31

Re: Lab 2 Task 1.1 confusion

Beitrag von sumitsati » 29. Nov 2015 11:13

I have no idea about the lab task and the details therein but this might help you:
"In all versions of UNIX, the time() system call may be used to obtain the
time of day. This call is peculiar in that if given the address of a long
integer as an argument, it places the time in that integer and returns it.
If, however, a null pointer is passed, the time of day is just returned.

Several routines are available to convert the long integer returned by time()
into an ASCII date string. With the UNIX operating system, an ASCII date
string is a string as shown below:"

So I am guessing a time function, you might be using, returns a long long integer. and given is the way to correctly display a long long integer.


Beiträge: 16
Registriert: 20. Okt 2015 11:36

Re: Lab 2 Task 1.1 confusion

Beitrag von schwahn » 30. Nov 2015 11:45

pranay hat geschrieben: So, do we need to show 23 Sec
OR (3600*3)+(23*60)+27 = 12203 Sec ??
In Unix-like systems, wall time is represented in seconds ( and this time is what you need to show. Also, showing the seconds fraction of the current minute does not make much sense, does it?


Zurück zu „Archiv“