How to remove double quotes from a string in C

1 Answer

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

int main(void) {
    char s[] = "\"c c++ \"node.js\" java c# python\"";
    int j = 0, len = strlen(s);;
    
    puts(s);
    
    for (int i = 0; i < len; i++) {
        if (s[i] != '"' && s[i] != '\\') { 
            s[j++] = s[i];
        } 
    }

    if (j > 0) s[j] = 0;

    puts(s);

    return 0;
}



/*
run:

"c c++ "node.js" java c# python"
c c++ node.js java c# python

*/

 



answered Feb 20, 2022 by avibootz

Related questions

2 answers 230 views
1 answer 135 views
1 answer 147 views
1 answer 133 views
1 answer 130 views
2 answers 177 views
...