Files
chat_application/message.c
2023-03-28 08:08:11 -05:00

27 lines
484 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "message.h"
Message new_message(char* string, User from, User to) {
Message new_message;
new_message.text = malloc((strlen(string)+1)*sizeof(char));
strcpy(new_message.text,string);
new_message.sender = from;
new_message.recipient = to;
time_t rawtime;
struct tm timeinfo;
time(&rawtime);
timeinfo = *localtime(&rawtime);
new_message.timeinfo = timeinfo;
return new_message;
}