Dynamically enumerating the members of a C++ struct
In C++ there is a struct with the following structure:
After some computations on the values of the struct members are inserted into a database table:
Given that the members of the struct can change, as well as currently close to 100 members, we are looking for a way to loop over the members in a dynamic fashion, without having to spell out each member individually.
Therefore the question is, is there a way to loop over the struct members so that the SQL that comes after the VALUES clause is updated based on however many struct members there are?
I receive an integer as argument for a function.
within function definition i want it to be of type struct tm.
eg..
main()
{
int a;
......
}
function(...,..,a,..)
int a;
{
struct tm tm;
if(!a)
^ time(&a);
^ ... (4 Replies)
I am trying to enumerate all hardware (plugged in devices) and I am using lshal source code from here:
Cross Reference: /onnv/onnv-gate/usr/src/cmd/hal/tools/lshal.c
and is missing information about plugged in monitors, and mouse and houppgae TV card. They came out in gnome device manager,... (0 Replies)
Hi,
I am working on gcov.Meaning, analysing the functionality of gcov. There is one structure called "struct bb". I am not sure, how struct bb members are getting assigned values. If anyone knows how it is happening pls let me know.
Thanks in advance.
--Vichu (0 Replies)
Can someone tell me how to do this?
Just a thought that entered my mind when learning about structs.
First thought was:
struct one
{
struct two;
}
struct two
{
three;
}
one->two->three
would this be how you would access "three"? (1 Reply)
In a well-known book on the C language, there is an example of an efficient method for using a struct member as an argument to a function. (I'm a C noob, but I believe the correct terminology might be: use call-by-reference instead of call-by-value.) The function is printf.
Anyway, here's a... (5 Replies)
Hi,
I have received an application that stores some properties in a file. The existing struct looks like this:
struct TData
{
UINT uSizeIncludingStrings;
// copy of Telnet data struct
UINT uSize;
// basic properties:
TCHAR szHost; //defined in Sshconfig
UINT iPortNr;
TCHAR... (2 Replies)
I have many headers with huge amount of structures in them, typical one looks like this:
$ cat a.h
struct Rec1 {
int f1;
int f2;
};
struct Rec2 {
char r1;
char r2;
};
struct Rec3 {
int f1;
float k1;
float ... (6 Replies)
Discussion started by: migurus
6 Replies
LEARN ABOUT SUNOS
ftime
ftime(3C) Standard C Library Functions ftime(3C)NAME
ftime - get date and time
SYNOPSIS
#include <sys/timeb.h>
int ftime(struct timeb *tp);
DESCRIPTION
The ftime() function sets the time and millitm members of the timeb structure pointed to by tp. The structure is defined in <sys/timeb.h>
and contains the following members:
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
The time and millitm members contain the seconds and milliseconds portions, respectively, of the current time in seconds since 00:00:00 UTC
(Coordinated Universal Time), January 1, 1970.
The timezone member contains the local time zone. The dstflag member contains a flag that, if non-zero, indicates that Daylight Saving time
applies locally during the appropriate part of the year.
The contents of the timezone and dstflag members of tp after a call to ftime() are unspecified.
RETURN VALUES
Upon successful completion, the ftime() function returns 0. Otherwise -1 is returned.
ERRORS
No errors are defined.
USAGE
For portability to implementations conforming to earlier versions of this document, time(2) is preferred over this function.
The millisecond value usually has a granularity greater than one due to the resolution of the system clock. Depending on any granularity
(particularly a granularity of one) renders code non-portable.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO date(1), time(2), ctime(3C), gettimeofday(3C), timezone(4), attributes(5), standards(5)SunOS 5.10 24 Jul 2002 ftime(3C)