// The following code is meant to prompt the user to enter a string and a // position, then remove the character at that position from the string. The // updated string, with the character deleted, is then printed to the screen. // // Unfortunately, this code contains a number of errors. // It's your job to fix them, good luck! #include #include #define SIZE 50 void delete_char_from_string(char input[SIZE], int position); void strip_newline(char *string); int main(void) { printf("Enter a string: ") char input[SIZE]; fgets(input, SIZE); strip_newline(input); printf("Enter a position to remove: "); scanf("%d", &position); delete_char_from_string(input[], position, 0); printf("Result: %s\n", input); return 0; } void delete_char_from_string(char string[SIZE], int position) { int i = position; while (i < strlen(string)) { string[i] = string[i + 1]; } } //////////////////////////////////////////////////////////////////////////////// // DO NOT CHANGE ANY OF THE CODE BELOW HERE // // The code below is correct as given. You do NOT need to modify it // //////////////////////////////////////////////////////////////////////////////// // Removes a newline character from end of the given string, if it exists. void strip_newline(char *string) { int length = strlen(string); if (length != 0 && string[length - 1] == '\n') { string[length - 1] = '\0'; } }