Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #102720 > unrolled thread
| Started by | fl <rxjwg98@gmail.com> |
|---|---|
| First post | 2017-01-29 11:04 -0800 |
| Last post | 2017-01-29 13:26 -0800 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.c
Could you explain what meanings are in this time help contents? fl <rxjwg98@gmail.com> - 2017-01-29 11:04 -0800
Re: Could you explain what meanings are in this time help contents? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-29 19:20 +0000
Re: Could you explain what meanings are in this time help contents? Keith Thompson <kst-u@mib.org> - 2017-01-29 13:26 -0800
| From | fl <rxjwg98@gmail.com> |
|---|---|
| Date | 2017-01-29 11:04 -0800 |
| Subject | Could you explain what meanings are in this time help contents? |
| Message-ID | <58fe223e-7877-4fab-a883-cbaf3ae7d809@googlegroups.com> |
Hi, I want to learn ctime usage. Accidentally see the following link: http://ps-2.kev009.com/wisclibrary/aix51/usr/share/man/info/en_US/a_doc_lib/libs/basetrf1/ctime.htm#SPTA0909BAC It is noticed that the first line in each pair has no ';' at the end. It is puzzling to me for their meanings. There are three same lines beginning with 'const'. Could you explain to me what each pair is for? Thanks in advance ..................... #include <time.h> char *ctime ( Clock) const time_t *Clock; struct tm *localtime (Clock) const time_t *Clock; struct tm *gmtime (Clock) const time_t *Clock; Parameters Clock Specifies the pointer to the time value in seconds.
[toc] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-01-29 19:20 +0000 |
| Message-ID | <87fuk1r7vh.fsf@bsb.me.uk> |
| In reply to | #102720 |
fl <rxjwg98@gmail.com> writes:
> I want to learn ctime usage. Accidentally see the following link:
>
> http://ps-2.kev009.com/wisclibrary/aix51/usr/share/man/info/en_US/a_doc_lib/libs/basetrf1/ctime.htm#SPTA0909BAC
<snip>
> char *ctime ( Clock)
> const time_t *Clock;
>
> struct tm *localtime (Clock)
> const time_t *Clock;
>
> struct tm *gmtime (Clock)
> const time_t *Clock;
<re-ordered>
> It is noticed that the first line in each pair has no ';' at the end.
> It is puzzling to me for their meanings.
> There are three same lines beginning with 'const'.
>
> Could you explain to me what each pair is for?
That's just old K&R C. In the days before ANSI (and later ISO) C a
function was defined by listing the parameter names in the ()s and then
giving the declarations before the opening { of the function body:
double square(x)
double x;
{
return x*x;
}
Of course there were no function prototypes, so writing
double square(x)
double x;
on it's own is not valid C (there must be a function body following the
declarations) but the best that old manual pages could do was show the
start of the function definition.
Nowadays, it would be written like this:
char *asctime(const struct tm *tm);
char *ctime(const time_t *timep);
struct tm *gmtime(const time_t *timep);
struct tm *localtime(const time_t *timep);
(Taken directly from "man ctime" on my machine.)
You should probably look for more up to date documentation.
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2017-01-29 13:26 -0800 |
| Message-ID | <lna8a9blsg.fsf@kst-u.example.com> |
| In reply to | #102720 |
fl <rxjwg98@gmail.com> writes:
> I want to learn ctime usage. Accidentally see the following link:
>
> http://ps-2.kev009.com/wisclibrary/aix51/usr/share/man/info/en_US/a_doc_lib/libs/basetrf1/ctime.htm#SPTA0909BAC
>
> It is noticed that the first line in each pair has no ';' at the end.
> It is puzzling to me for their meanings.
> There are three same lines beginning with 'const'.
>
> Could you explain to me what each pair is for?
[...]
> #include <time.h>
>
>
> char *ctime ( Clock)
> const time_t *Clock;
This is part of an old-style (pre-ANSI) function declaration.
This form is still legal, but there is no good reason to use it
(unless you're stuck with a *very* old compiler, but that's not
likely). The modern and more correct declaration, copy-and-pasted
from the C Standard, is:
char *ctime(const time_t *timer);
The name of the parameter is not particularly relevant, but "timer" is
what's used in the standard. The name "Clock" is poorly chosen, since
there's a clock() function with a quite different meaning.
That web page is part of a technical reference for AIX, a flavor of UNIX
from IBM. It seems to be fairly old. Unless you're using an old
version of AIX for some reason, I strongly suggest you find a better
reference.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web