// 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() { char str1[50]; char str2[50]; char concat[100]; int length1; int length2; printf("Enter the first string: "); fgets(str1, 50, stdin); //scanf("%s", &str1); strip_newline(str1); printf("Enter the second string: "); fgets(str2, 50, stdin); strip_newline(str2); length1 = strlen(str1); length2 = strlen(str2); if (length1 + length2 > 100) { printf("Error: Strings are too long to concatenate\n"); return 1; } // i = 0; i <= 8; i++ for (int i = 0; i < length1; i++) { //concat[0] = str[0] = P //concat[1] = str[1] = a //concat[2] = str[2] = s //concat[3] = str[3] = s concat[i] = str1[i]; } // i = 3 for (int i = length1; i <= length1 + length2; i++) { concat[i] = str2[i - length1]; } printf("%s\n", concat); 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'; } }