You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
742 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 = malloc(sizeof(Message));
new_message->text = malloc((strlen(string)+1)*sizeof(char));
strcpy(new_message->text,string);
new_message->sender = malloc(sizeof(User));
new_message->recipient = malloc(sizeof(User));
memcpy(new_message->sender, from, sizeof(User));
memcpy(new_message->recipient, to, sizeof(User));
// *(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;
}