Skip to content
Snippets Groups Projects
Commit cb1c3ce5 authored by ChouTatsumi's avatar ChouTatsumi
Browse files

test 21:08

parent d7529b19
No related branches found
No related tags found
No related merge requests found
...@@ -378,19 +378,16 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added, ...@@ -378,19 +378,16 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
bool show_start_page(int sockfd, char* username) { bool show_start_page(int sockfd, char* username) {
int username_length = strlen(username); int username_length = strlen(username);
char* added_prefix = "<p>"; char* added_prefix = "<p>";
int added_prefix_length = strlen(added_prefix);
char* added_suffix = "</p>\n\n"; char* added_suffix = "</p>\n\n";
int added_suffix_length = sizeof(added_suffix);
// the length needs to include the html tags for the username // the length needs to include the html tags for the username
int added_length = username_length + 9; int added_length = username_length + 9;
char added[added_length]; char added[added_length];
// create added string // create added string
strncpy(added, added_prefix, added_prefix_length); strcat(added, added_prefix);
strncpy(added + added_prefix_length, username, username_length); strcat(added, username);
strncpy(added + added_prefix_length + username_length, added_suffix, strcat(added, added_suffix);
added_suffix_length);
return show_modified_page(sockfd, START_PAGE, added, 212); return show_modified_page(sockfd, START_PAGE, added, 212);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment