Accessing a struct inside struct
How can I call the ru_stime and ru_ctime members. Since the both belong to struct timeval inside struct rusage.
#include<iostream>
using namespace std;
#include<unistd.h>
#include<sys/resource.h>
#include<errno.h>
#include<sys/time.h>
int main()
{
struct rusage* resource= new struct rusage;
if( getrusage(RUSAGE_SELF, resource) == -1 ){
perror("getrusage error");
exit(1);
}
cout<<"The ru_stime is "<<resource->timeval.ru_stime<<endl;
cout<<"The ru_utime is "<<resource->timeval.ru_utime<<endl;
cout<<endl;
return 0;
}
|