Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Memory fault(coredump) with time() function.
@ 1999-01-20  5:00 jasperh
  1999-01-20  5:00 ` John Hascall
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jasperh @ 1999-01-20  5:00 UTC (permalink / raw)


I get a Memory fault (coredump) when using the time() function in the
following C code:

I tried it on a DecUnix 3.2 and a 3.2c box.
Many thanks.

Part of the C code follows:

#include <stdio.h>
#include <prot.h>
#include <time.h>
#include <locale.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/security.h>
#include <sys/stat.h>

main(argc, argv, envp)
int argc;
char *argv[], *envp[];
{
char *name;
int current_time;
current_time=time();       
printf("now=%d\n", time());
}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Memory fault(coredump) with time() function.
  1999-01-20  5:00 Memory fault(coredump) with time() function jasperh
@ 1999-01-20  5:00 ` John Hascall
  1999-01-20  5:00 ` Joe Mario
  1999-01-25  5:00 ` Ajay Pal Singh
  2 siblings, 0 replies; 4+ messages in thread
From: John Hascall @ 1999-01-20  5:00 UTC (permalink / raw)


jasperh <jasperh@debis.co.za> wrote:
}I get a Memory fault (coredump) when using the time() function in the
}following C code:
}int current_time;
}current_time=time();       
}printf("now=%d\n", time());

    time has an argument, use:

   printf("now=%d\n", time(NULL));


John
-- 
John Hascall, Software Engr.      Shut up, be happy.  The conveniences you
ISU Computation Center            demanded are now mandatory. -Jello Biafra
mailto:john@iastate.edu
http://www.cc.iastate.edu/staff/systems/john/index.html  <=- the usual crud



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Memory fault(coredump) with time() function.
  1999-01-20  5:00 Memory fault(coredump) with time() function jasperh
  1999-01-20  5:00 ` John Hascall
@ 1999-01-20  5:00 ` Joe Mario
  1999-01-25  5:00 ` Ajay Pal Singh
  2 siblings, 0 replies; 4+ messages in thread
From: Joe Mario @ 1999-01-20  5:00 UTC (permalink / raw)
  To: jasperh

jasperh wrote:
> 
> I get a Memory fault (coredump) when using the time() function in the
> following C code:
  ...
> int current_time;
> current_time=time();       
> printf("now=%d\n", time()); 

The time function you are calling expects a parameter.  The coredump
occurs because you didn't supply one.  If you try compiling in
either of the ansi modes (-std or -std1), you'll see the compiler
give a compile time error about the missing argument.
Try "man 3 time".

Joe Mario
Compaq Digital UNIX



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Memory fault(coredump) with time() function.
  1999-01-20  5:00 Memory fault(coredump) with time() function jasperh
  1999-01-20  5:00 ` John Hascall
  1999-01-20  5:00 ` Joe Mario
@ 1999-01-25  5:00 ` Ajay Pal Singh
  2 siblings, 0 replies; 4+ messages in thread
From: Ajay Pal Singh @ 1999-01-25  5:00 UTC (permalink / raw)
  To: jasperh

You need to check man pages for time(3).
$ man 3 time

Here's the way it'll work.

long time_var;
time=(&time_var);    /* You can check for error here */
printf("%s", ctime(&time_var));

regards.

jasperh wrote:

> I get a Memory fault (coredump) when using the time() function in the
> following C code:
>
> I tried it on a DecUnix 3.2 and a 3.2c box.
> Many thanks.






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-01-25  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-01-20  5:00 Memory fault(coredump) with time() function jasperh
1999-01-20  5:00 ` John Hascall
1999-01-20  5:00 ` Joe Mario
1999-01-25  5:00 ` Ajay Pal Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox