remove \n from string c
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "This is a string\n without newline";
int len = strlen(str);
for (int i = 0; i < len; i++) {
if (str[i] == '\n') {
for (int j = i; j < len; j++) {
str[j] = str[j + 1];
}
len--;
i--;
}
}
printf("%s", str);
return 0;
}