How to remove \n from the middle of a string in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

int main() {
    char s[] = "c \n c++";

    s[strcspn(s, "\n")] = ' ';

    puts(s);

    return 0;
}




/*
run:

c   c++

*/

 



answered Mar 16, 2022 by avibootz

Related questions

1 answer 119 views
1 answer 113 views
1 answer 112 views
1 answer 147 views
...