How do I write the in C++, it's should be called from a program a made i C++Builder, but I can't call it when it is written in C.
It comes up with a error:
canot convert 'void *' to 'char *'
I need to call a time function, which gets the time from the system.
---------------------code clip
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <dos.h>
char* GetTheTime(void);
int freeAllocated(void);
char* GetTheTime()
{
char *Time = malloc(sizeof(char)*256);
struct time t;
gettime(&t);
sprintf(Time,"The current time is: %2d:%02d:%02d\n", t.ti_hour, t.ti_min, t.ti_sec);
return Time;
}
int freeAllocated()
{
char* CurrentTime;
CurrentTime = GetTheTime();
free(CurrentTime);
return 0;
}
int main()
{
printf("HER er klokken \n\n");
puts(GetTheTime());
getch();
printf("\n Saa free'er vi\n");
freeAllocated();
getch();
return 0;
}