|
|
@ -50,14 +50,24 @@ char* fetch_message_string(char* message) {
|
|
|
|
num_of_terminators = 1;
|
|
|
|
num_of_terminators = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end_index -= num_of_terminators;
|
|
|
|
|
|
|
|
|
|
|
|
int message_length = end_index - start_index;
|
|
|
|
int message_length = end_index - start_index;
|
|
|
|
char* message_string = malloc(message_length + 1);
|
|
|
|
char* message_string = malloc(message_length + 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Message length is %d\n",message_length);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0;i < message_length-num_of_terminators; i++) { /* The reason the upper-bound is message_length-1 is because the last
|
|
|
|
for (int i=0; i<message_length; i++) { /* The reason the upper-bound is message_length-1 is because the last
|
|
|
|
character is a new-line, which the user would not have typed. */
|
|
|
|
character is a new-line, which the user would not have typed. */
|
|
|
|
|
|
|
|
|
|
|
|
*(message_string + i) = *(message + start_index + i);
|
|
|
|
*(message_string + i) = *(message + start_index + i);
|
|
|
|
|
|
|
|
printf("%c",*(message_string + i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*(message_string + (message_length - num_of_terminators)) = '\0';
|
|
|
|
strcat(message_string,"\0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("%s\n",message_string);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// *(message_string + (message_length - num_of_terminators)) = '\0';
|
|
|
|
return message_string;
|
|
|
|
return message_string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|