How to remove the last comma from the end of string in C

1 Answer

0 votes
#include <stdio.h>

int main()
{
    char s[] = "c,c++,java,python,";

    int size = sizeof(s)/sizeof(s[0]);

    s[size - 2] = 0;

    printf("%s\n", s);

    return 0;
}




/*
run:

c,c++,java,python

*/

 



answered Apr 12, 2022 by avibootz

Related questions

1 answer 152 views
1 answer 137 views
1 answer 196 views
1 answer 165 views
1 answer 149 views
2 answers 201 views
2 answers 200 views
...