Hi!
I'm trying to a) stuff a dereferenced value from a pointer to long
into a pointer to char. W'ere talking about sysUpTime here. I use the
following code, but no matter what, i only get 4 characters/digits.
What is the problem? %lu does not give me much help, so i tried
padding it myself with some bytes.
if(vars->type==ASN_TIMETICKS) {
if(i==1) {
/* sizeof(*vars->val.integer= long/int probably 4 bytes.
+8 for some digits in precision
+1 for the NULL terminated string */
data->sysUpTime=malloc(sizeof(*vars->val.integer)+8+1);
sprintf(data->sysUpTime,"%lu",*vars->val.integer);
data->sysUpTime[sizeof(*vars->val.integer)]='\0';
}
}
The other question i have is, how do i calculate the uptime in days,
because all i have is the number of timeticks. Or can you actually
read out the days. I don't think so, so there must be some algorithm
for that.
Many thanks,
Alef
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders