I have a code that is supposed to get the time , I want to store the time in my char array but I cannot do that so , I thought that I could have a loop to a pointer and loop through the pointer and copy the chars from the pointer memory to my char, is that possible?
void My_Time(char *myt_Time,int size)
{
time_t raw_Time = time(0);
struct tm *info;
char *myt_Temp;
int x;
info = localtime(&raw_Time);
myt_Temp = asctime(info);
for (x=0;x<size;x++)
{
myt_Time[x]=myt_Temp;
}
}
myt_Temp. You can usestrncpyto do this, instead of writing your own loop.myt_Time[x] = myt_Temp[x].