// The following code is meant to take two string inputs from the user and // concatenate them together. However, there are a number of mistakes in the // code that are causing it to not work as intended. Can you find and fix the // errors? Good luck! #include #include void strip_newline(char *string); int main(void) { char str1[50]; char str2[50]; char concat[100]; int length1; int length2; printf("Enter the first string: "); fgets(&str1, 50, stdin); strip_newline(str1); printf("Enter the second string: "); fgets(&str2, 50, stdin); strip_newline(str2); length1 = strlen(str1); length2 = strlen(str2); if (len1 + len2 >= 100) { printf("Error: Strings are too long to concatenate\n"); return 1; } for (int i = 0; i <=len1 + len2; i++) { concat[i] = str1[i]; } for (int i = len1; i <= len2; i++) { concat[i] = str2[i]; } printf("%c\n", concat[0]); return 0; } // Removes newline from end of the given string if it exists // NOTE: This function is correct as given. // You do not need to modify it for this question. void strip_newline(char *string) { int length = strlen(string); if (length != 0 && string[length - 1] == '\n') { string[length - 1] = '\0'; } }