Yes it contains both of 'em
Main Topics
Browse All TopicsHi there
can anyone help me with a c program to get time in milliseconds.I was in Linux platform and want to record some values in milliseconds.I have used sleep but could get in seconds.I want to have the values to be in milliseconds.Hence i have tried to use the following script
#include <time.h>
struct timespec ts;
main(int argc, char** argv)
{
/* Delay for a bit */
ts.tv_sec = 0;
ts.tv_nsec = argv[1];
nanosleep (&ts, NULL);
}
However it displays the following when compiled in Dev c ++
Error::::: aggregate ‘struct timespec ts ‘ has incomplete type and cannot be initialized
Can anyone help me with this please
Thank you
chris
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Chris, you've to use GETSYSTEMTIME. The following is from MS WIN SDK HELP:
The GetSystemTime function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC).
VOID GetSystemTime(
LPSYSTEMTIME lpSystemTime // address of system time structure
);
Parameters
lpSystemTime
Points to a SYSTEMTIME structure to receive the current system date and time.
Return Values
This function does not return a value.
typedef struct _SYSTEMTIME { // st
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
BR
Berthold
Business Accounts
Answer for Membership
by: Infinity08Posted on 2007-02-22 at 15:25:01ID: 18592548
Check the time.h header file. Does it contain the definition for struct timespec and nanosleep ?