What you will want to do is return a char*, so it would look like this:
Code:
char* GetTime()
{
char *Time = malloc(sizeof(char)*256);
struct time t;
gettime(&t);
snprintf(Time, 256, "The current time is: %2d:%02d:%02d\n", t.ti_hour, t.ti_min, t.ti_sec);
return Time;
}
What it does is create a char* called Time. Time is created with a size of 256. snprintf stores the message like printf into a string (Time). Then the time is returned. You could call GetTime() like this:
Code:
char* CurrentTime;
CurrentTime = GetTime();
//Later in your program you need to free CurrentTime
free(CurrentTime);
- Sean