how to remove \n from a string c
#include <stdio.h>
#include <string.h>
void removeNewLine(char *str) {
int length = strlen(str);
if (str[length - 1] == '\n') {
str[length - 1] = '\0';
}
}
int main() {
char input[100];
printf("Enter a string with '\\n' at the end: ");
fgets(input, sizeof(input), stdin);
removeNewLine(input);
printf("String after removing '\\n': %s\n", input);
return 0;
}