Is it possible to copy the output of a command used on system() function on Linux? E.g., If I run
#include <stdlib.h>
int main(int argc,char *argv[]){
char date[8]; //e.g., 20130421 yyyymmdd
char time[4]; // e.g., 0204 hhmm
system("ntpdate");
return 0;
}
it outputs:
21 Apr 02:12:56 ntpdate[32680]: no servers can be used, exiting
is it possible to copy the output to a string? how can I copy the date and time info to a char array e.g. char *date ; char *time on C?