Linux - Getdate question and calling another program

  • Thread starter Yann Laviolette
  • Start date
Y

Yann Laviolette

Hi!

I look for a function like the Windows function getdate(&d); and
gettime(&t); to have the date and the time. Also I look for a function
like spawnl to call another program. These function should work with
Linux.

Can somebody help me?

Thanks a lot!

Yann
 
J

Jack Klein

Hi!

I look for a function like the Windows function getdate(&d); and
gettime(&t); to have the date and the time. Also I look for a function
like spawnl to call another program. These function should work with
Linux.

Can somebody help me?

Thanks a lot!

Yann

Standard C, the topic here, provides the function time() prototyped in
<time.h> for getting the current system date and time. It also
provides the standard library function system() prototyped in
<stdlib.h> which may be able to launch external programs. Look them
up in your compiler's library documentation, man pages, or help files.

None of the functions you mentioned are part of standard C, so they
are all off-topic here. If you want Linux specific answers, ask in a
Linux programming group such as
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
T

Tristan Miller

Greetings.

Yann Laviolette said:
I look for a function like the Windows function getdate(&d); and
gettime(&t); to have the date and the time.

Without more information on what exactly getdate() and gettime() are
supposed to do, I can only recommend the following:

#include <time.h>

time_t time(time_t *t);

(IIRC, even this isn't guaranteed to work, as C doesn't require that the
system have a clock.)
Also I look for a function
like spawnl to call another program.

"Call" in what way? The standard way is to use the system() function
defined in <stdlib.h>, though you may be looking for a POSIX-style fork()
exec(). The latter isn't standard C, but is widely supported on most Un*x
compilers, including those for Linux.
These function should work with Linux.

The above will work on Linux, or for that matter on any other system with a
conformant C compiler.

If you want something more specific to Linux, you'll have to ask in a
newsgroup catering to that platform. Try a gcc newsgroup.
 
Y

Yann Laviolette

Le Sun, 02 Nov 2003 21:27:54 +0000, Jack Klein a écrit :

Thanks a lot Jack! You help me a lot! My problem is now solve.

Byebye!

Yann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top