Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #157612
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: I need help understand some c code |
| Date | 2020-12-21 20:03 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87a6u7udt2.fsf@bsb.me.uk> (permalink) |
| References | <rrp1gb$kle$1@dont-email.me> |
T <T@invalid.invalid> writes:
> I am trying to use Raku's native call to read the
> time in Linux.
>
> I found this C code:
>
> #include<stdio.h>
> #include<time.h>
>
> void main()
> {
> time_t t;
> time(&t);
> printf("\n current time is : %s",ctime(&t));
> }
>
>
> What is "time_t t" and why the space?
time_t a type (most likely a 64-bit integer type).
> What is "time($t)"?
It's &t. &t is the address of t -- a pointer to the t object. The time
function is odd for historical reasons. It returns the time and also
allows the time to be placed into an object whose address is passed to
the function.
> I also need to know the length in bit.
You don't really need to know anything except this last one. It is
likely that int64 is the correct Raku type to use. All the rest is
about Raku's NativeCall, not C:
$ cat time.p6
use NativeCall;
sub time(int64 is rw) returns int64 is native { * }
sub ctime(int64 is rw) returns Str is native { * }
time(my int64 $t);
print ctime($t);
$ perl6 time.p6
Mon Dec 21 20:02:18 2020
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
I need help understand some c code T <T@invalid.invalid> - 2020-12-20 18:32 -0800
Re: I need help understand some c code Siri Cruise <chine.bleu@yahoo.com> - 2020-12-20 19:03 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 19:56 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 20:02 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 20:43 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 21:06 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 21:56 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 20:33 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 20:51 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 21:11 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 22:10 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 22:15 -0800
Re: I need help understand some c code Bart <bc@freeuk.com> - 2020-12-21 13:11 +0000
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-21 13:47 -0800
Re: I need help understand some c code scott@slp53.sl.home (Scott Lurndal) - 2020-12-23 17:18 +0000
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-23 12:05 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-21 14:25 -0800
Re: I need help understand some c code Bonita Montero <Bonita.Montero@gmail.com> - 2020-12-21 05:45 +0100
Re: I need help understand some c code Bart <bc@freeuk.com> - 2020-12-21 12:16 +0000
Re: I need help understand some c code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-12-21 20:03 +0000
csiph-web