Ideas:
1, formatted to read the two number of files, saved in two strings.
2,/proc/uptime in seconds, discard decimal. Converts the integer part to long.
3, from long to date.
#include <stdio.h>
int main ()
{
FILE *fp = NULL;
fp = fopen ("uptime.c", "R");
if (fp = = NULL)
{
printf ("Open File failed!\n");
return 0;
}
Save two numbers, the length is slightly larger than the number of files
//You can use Cat/proc/uptime in advance to see
char t[20];
Char u[20];
FSCANF (FP, "%s", T, u);
Count the number of integer digits of the first number, and turn to long, omitting the 2nd number processing
unsigned long dt = 0;
int i;
For (i=0 i<20; i++)
{
if (t[i] = = '. ')
break;
int j = 1;
For (i--i>=0; i--)
{
dt + = (t[i]-' 0 ') * j;
J *=;
Long turns to date and outputs
unsigned long day, hour, minute, second;
Day = dt/(60*60*24);
DT = dt% (60*60*24);
hour = DT/(60*60);
DT = dt% (60*60);
minute = DT/60;
second = dt%;
printf ("%ld:%ld:%ld:%ld\n", day, hour, minute, second);
Fclose (FP);
return 0;
}